From 56fac707054f7586cdfd08d15469b7c3c283fe28 Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Wed, 9 Sep 2020 12:55:43 +0800 Subject: [PATCH] BookSource.kt: Modify redundant procedure Signed-off-by: 1552980358 <1552980358@qq.com> --- .../io/legado/app/data/entities/BookSource.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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) } }