Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Mar 15, 2023
2 parents 349ab62 + 2a7316e commit 22e41d6
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,29 +113,27 @@ class AnalyzeUrl(
*/
private fun analyzeJs() {
var start = 0
var tmp: String
val jsMatcher = JS_PATTERN.matcher(ruleUrl)
var hasRule = true
var result = ruleUrl
while (jsMatcher.find()) {
if (jsMatcher.start() > start) {
tmp =
ruleUrl.substring(start, jsMatcher.start()).trim { it <= ' ' }
if (tmp.isNotEmpty()) {
ruleUrl = tmp.replace("@result", ruleUrl)
ruleUrl.substring(start, jsMatcher.start()).trim().let {
if (it.isNotEmpty()) {
result = it.replace("@result", result)
}
}
}
ruleUrl = evalJS(jsMatcher.group(2) ?: jsMatcher.group(1), ruleUrl) as String
result = evalJS(jsMatcher.group(2) ?: jsMatcher.group(1), result) as String
start = jsMatcher.end()
if (jsMatcher.group(0)!!.startsWith("@js:", true)) {
hasRule = false
}
}
if (ruleUrl.length > start && hasRule) {
tmp = ruleUrl.substring(start).trim { it <= ' ' }
if (tmp.isNotEmpty()) {
ruleUrl = tmp.replace("@result", ruleUrl)
if (ruleUrl.length > start) {
ruleUrl.substring(start).trim().let {
if (it.isNotEmpty()) {
result = it.replace("@result", result)
}
}
}
ruleUrl = result
}

/**
Expand Down

0 comments on commit 22e41d6

Please sign in to comment.