diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index a5d7ebf56..bddfe1ab5 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -54,14 +54,15 @@ data class BookSource( fun getHeaderMap() = (HashMap().apply { this[AppConst.UA_NAME] = App.INSTANCE.getPrefString("user_agent") ?: userAgent header?.let { - val header1 = when { - it.startsWith("@js:", true) -> - evalJS(it.substring(4)).toString() - it.startsWith("", true) -> - evalJS(it.substring(4, it.lastIndexOf("<"))).toString() - else -> it - } - GSON.fromJsonObject>(header1)?.let { map -> + GSON.fromJsonObject>( + when { + it.startsWith("@js:", true) -> + evalJS(it.substring(4)).toString() + it.startsWith("", true) -> + evalJS(it.substring(4, it.lastIndexOf("<"))).toString() + else -> it + } + )?.let { map -> putAll(map) } }