Merge remote-tracking branch 'origin/master'

pull/395/head
Celeter 4 years ago
commit 0ebbf1a939
  1. 69
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -447,39 +447,44 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
else -> rule = ruleStr else -> rule = ruleStr
} }
} }
//分离put if (mode == Mode.Js) {
rule = splitPutRule(rule, putMap) ruleType.add(defaultRuleType)
//@get,{{ }}, 拆分 ruleParam.add(rule)
var start = 0 } else {
var tmp: String //分离put
val evalMatcher = evalPattern.matcher(rule) rule = splitPutRule(rule, putMap)
while (evalMatcher.find()) { //@get,{{ }}, 拆分
if (evalMatcher.start() > start) { var start = 0
tmp = rule.substring(start, evalMatcher.start()) var tmp: String
if (start == 0 && !tmp.contains("##") && mode != Mode.Js) { val evalMatcher = evalPattern.matcher(rule)
mode = Mode.Regex while (evalMatcher.find()) {
} if (evalMatcher.start() > start) {
splitRegex(tmp) tmp = rule.substring(start, evalMatcher.start())
} if (start == 0 && !tmp.contains("##")) {
tmp = evalMatcher.group() mode = Mode.Regex
when { }
tmp.startsWith("@get:", true) -> {
ruleType.add(getRuleType)
ruleParam.add(tmp.substring(6, tmp.lastIndex))
}
tmp.startsWith("{{") -> {
ruleType.add(jsRuleType)
ruleParam.add(tmp.substring(2, tmp.length - 2))
}
else -> {
splitRegex(tmp) splitRegex(tmp)
} }
tmp = evalMatcher.group()
when {
tmp.startsWith("@get:", true) -> {
ruleType.add(getRuleType)
ruleParam.add(tmp.substring(6, tmp.lastIndex))
}
tmp.startsWith("{{") -> {
ruleType.add(jsRuleType)
ruleParam.add(tmp.substring(2, tmp.length - 2))
}
else -> {
splitRegex(tmp)
}
}
start = evalMatcher.end()
}
if (rule.length > start) {
tmp = rule.substring(start)
splitRegex(tmp)
} }
start = evalMatcher.end()
}
if (rule.length > start) {
tmp = rule.substring(start)
splitRegex(tmp)
} }
} }
@ -492,9 +497,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
val ruleStrArray = ruleStr.split("##") val ruleStrArray = ruleStr.split("##")
val regexMatcher = regexPattern.matcher(ruleStrArray[0]) val regexMatcher = regexPattern.matcher(ruleStrArray[0])
while (regexMatcher.find()) { while (regexMatcher.find()) {
if (mode != Mode.Js) { mode = Mode.Regex
mode = Mode.Regex
}
if (regexMatcher.start() > start) { if (regexMatcher.start() > start) {
tmp = ruleStr.substring(start, regexMatcher.start()) tmp = ruleStr.substring(start, regexMatcher.start())
ruleType.add(defaultRuleType) ruleType.add(defaultRuleType)

Loading…
Cancel
Save