From 0b0c8a461d6ec2a97bc80659a220aa7b64df34f1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 Nov 2019 22:51:00 +0800 Subject: [PATCH] up --- .../app/model/analyzeRule/AnalyzeRule.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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 6b000211a..adc7a3384 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 @@ -190,16 +190,18 @@ class AnalyzeRule(var book: BaseBook? = null) { putRule(sourceRule.putMap) sourceRule.makeUpRule(result) result?.let { - result = when (sourceRule.mode) { - Mode.Js -> evalJS(sourceRule.rule, it) - Mode.Json -> getAnalyzeByJSonPath(it).getString(sourceRule.rule) - Mode.XPath -> getAnalyzeByXPath(it).getString(sourceRule.rule) - Mode.Default -> if (isUrl) { - getAnalyzeByJSoup(it).getString0(sourceRule.rule) - } else { - getAnalyzeByJSoup(it).getString(sourceRule.rule) + if (sourceRule.rule.isNotBlank() || sourceRule.replaceRegex.isEmpty()) { + result = when (sourceRule.mode) { + Mode.Js -> evalJS(sourceRule.rule, it) + Mode.Json -> getAnalyzeByJSonPath(it).getString(sourceRule.rule) + Mode.XPath -> getAnalyzeByXPath(it).getString(sourceRule.rule) + Mode.Default -> if (isUrl) { + getAnalyzeByJSoup(it).getString0(sourceRule.rule) + } else { + getAnalyzeByJSoup(it).getString(sourceRule.rule) + } + else -> sourceRule.rule } - else -> sourceRule.rule } if (sourceRule.replaceRegex.isNotEmpty()) { result = replaceRegex(result.toString(), sourceRule)