BookSource.kt: Modify redundant procedure

Signed-off-by: 1552980358 <1552980358@qq.com>
pull/369/head
1552980358 4 years ago
parent 7005ad9291
commit 56fac70705
  1. 5
      app/src/main/java/io/legado/app/data/entities/BookSource.kt

@ -54,14 +54,15 @@ data class BookSource(
fun getHeaderMap() = (HashMap<String, String>().apply { fun getHeaderMap() = (HashMap<String, String>().apply {
this[AppConst.UA_NAME] = App.INSTANCE.getPrefString("user_agent") ?: userAgent this[AppConst.UA_NAME] = App.INSTANCE.getPrefString("user_agent") ?: userAgent
header?.let { header?.let {
val header1 = when { GSON.fromJsonObject<Map<String, String>>(
when {
it.startsWith("@js:", true) -> it.startsWith("@js:", true) ->
evalJS(it.substring(4)).toString() evalJS(it.substring(4)).toString()
it.startsWith("<js>", true) -> it.startsWith("<js>", true) ->
evalJS(it.substring(4, it.lastIndexOf("<"))).toString() evalJS(it.substring(4, it.lastIndexOf("<"))).toString()
else -> it else -> it
} }
GSON.fromJsonObject<Map<String, String>>(header1)?.let { map -> )?.let { map ->
putAll(map) putAll(map)
} }
} }

Loading…
Cancel
Save