diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt index 726fb943a..3ba6a3e26 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt @@ -33,15 +33,19 @@ class AnalyzeByXPath { val jxNodes = ArrayList() val elementsType: String val rules: Array - if (xPath.contains("&&")) { - rules = xPath.split("&&").dropLastWhile { it.isEmpty() }.toTypedArray() - elementsType = "&" - } else if (xPath.contains("%%")) { - rules = xPath.split("%%").dropLastWhile { it.isEmpty() }.toTypedArray() - elementsType = "%" - } else { - rules = xPath.split("||").dropLastWhile { it.isEmpty() }.toTypedArray() - elementsType = "|" + when { + xPath.contains("&&") -> { + rules = xPath.split("&&").dropLastWhile { it.isEmpty() }.toTypedArray() + elementsType = "&" + } + xPath.contains("%%") -> { + rules = xPath.split("%%").dropLastWhile { it.isEmpty() }.toTypedArray() + elementsType = "%" + } + else -> { + rules = xPath.split("||").dropLastWhile { it.isEmpty() }.toTypedArray() + elementsType = "|" + } } if (rules.size == 1) { return jxDocument!!.selN(rules[0]) @@ -79,15 +83,19 @@ class AnalyzeByXPath { val result = ArrayList() val elementsType: String val rules: Array - if (xPath.contains("&&")) { - rules = xPath.split("&&").dropLastWhile { it.isEmpty() }.toTypedArray() - elementsType = "&" - } else if (xPath.contains("%%")) { - rules = xPath.split("%%").dropLastWhile { it.isEmpty() }.toTypedArray() - elementsType = "%" - } else { - rules = xPath.split("||").dropLastWhile { it.isEmpty() }.toTypedArray() - elementsType = "|" + when { + xPath.contains("&&") -> { + rules = xPath.split("&&").dropLastWhile { it.isEmpty() }.toTypedArray() + elementsType = "&" + } + xPath.contains("%%") -> { + rules = xPath.split("%%").dropLastWhile { it.isEmpty() }.toTypedArray() + elementsType = "%" + } + else -> { + rules = xPath.split("||").dropLastWhile { it.isEmpty() }.toTypedArray() + elementsType = "|" + } } if (rules.size == 1) { val jxNodes = jxDocument!!.selN(xPath)