pull/38/head
kunfei 5 years ago
parent 0b7e210051
commit 52e4d43191
  1. 11
      app/src/main/java/io/legado/app/data/entities/BookSource.kt

@ -70,8 +70,15 @@ data class BookSource(
val headerMap = HashMap<String, String>()
headerMap["User-Agent"] = App.INSTANCE.getPrefString("user_agent") ?: userAgent
header?.let {
GSON.fromJsonObject<Map<String, String>>(header)?.let {
headerMap.putAll(it)
val header1 = when {
it.startsWith("@js:", true) ->
AppConst.SCRIPT_ENGINE.eval(it.substring(4)).toString()
it.startsWith("<js>", true) ->
AppConst.SCRIPT_ENGINE.eval(it.substring(4, it.lastIndexOf("<"))).toString()
else -> it
}
GSON.fromJsonObject<Map<String, String>>(header1)?.let { headers ->
headerMap.putAll(headers)
}
}
return headerMap

Loading…
Cancel
Save