mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user