diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index a1d75941c..5445884bf 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -231,7 +231,9 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { if (result == null) result = "" val str = kotlin.runCatching { Entities.unescape(result.toString()) - }.getOrDefault(result.toString()) + }.getOrElse { + result.toString() + } if (isUrl) { return if (str.isBlank()) { baseUrl ?: "" diff --git a/app/src/main/java/io/legado/app/utils/StringUtils.kt b/app/src/main/java/io/legado/app/utils/StringUtils.kt index 89d561cbf..b810ffa0d 100644 --- a/app/src/main/java/io/legado/app/utils/StringUtils.kt +++ b/app/src/main/java/io/legado/app/utils/StringUtils.kt @@ -214,12 +214,11 @@ object StringUtils { fun stringToInt(str: String?): Int { if (str != null) { val num = fullToHalf(str).replace("\\s+".toRegex(), "") - return try { + return kotlin.runCatching { Integer.parseInt(num) - } catch (e: Exception) { + }.getOrElse { chineseNumToInt(num) } - } return -1 }