diff --git a/app/src/main/java/io/legado/app/data/entities/BaseSource.kt b/app/src/main/java/io/legado/app/data/entities/BaseSource.kt index d9453a8f5..93cb5723e 100644 --- a/app/src/main/java/io/legado/app/data/entities/BaseSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BaseSource.kt @@ -13,7 +13,11 @@ import io.legado.app.help.SymmetricCryptoAndroid import io.legado.app.help.config.AppConfig import io.legado.app.help.http.CookieStore import io.legado.app.model.SharedJsScope -import io.legado.app.utils.* +import io.legado.app.utils.GSON +import io.legado.app.utils.fromJsonArray +import io.legado.app.utils.fromJsonObject +import io.legado.app.utils.has +import io.legado.app.utils.printOnDebug import org.intellij.lang.annotations.Language import org.mozilla.javascript.Scriptable @@ -99,19 +103,13 @@ interface BaseSource : JsExtensions { */ fun getHeaderMap(hasLoginHeader: Boolean = false) = HashMap().apply { header?.let { - val savedHeader = it - header = null - val json = try { - when { - it.startsWith("@js:", true) -> evalJS(it.substring(4)).toString() - it.startsWith("", true) -> evalJS( - it.substring(4, it.lastIndexOf("<")) - ).toString() + val json = when { + it.startsWith("@js:", true) -> evalJS(it.substring(4)).toString() + it.startsWith("", true) -> evalJS( + it.substring(4, it.lastIndexOf("<")) + ).toString() - else -> it - } - } finally { - header = savedHeader + else -> it } GSON.fromJsonObject>(json).getOrNull()?.let { map -> putAll(map)