Explorar el Código

先改回来
现在这样的url无法正确识别了
http://android.jjwxc.net/androidapi/search?keyword={{key}}&type=1&page={{page}}&searchType=7&sortMode=DESC
@js:java.put('key',key);java.put('page',page);result

kunfei hace 3 años
padre
commit
15cc4a6c1b
Se han modificado 1 ficheros con 15 adiciones y 13 borrados
  1. 15 13
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

+ 15 - 13
app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@@ -113,27 +113,29 @@ class AnalyzeUrl(
      */
     private fun analyzeJs() {
         var start = 0
+        var tmp: String
         val jsMatcher = JS_PATTERN.matcher(ruleUrl)
-        var result = ruleUrl
+        var hasRule = true
         while (jsMatcher.find()) {
-            if (jsMatcher.start() > start && start > 0) {
-                ruleUrl.substring(start, jsMatcher.start()).trim().let {
-                    if (it.isNotEmpty()) {
-                        result = it.replace("@result", result)
-                    }
+            if (jsMatcher.start() > start) {
+                tmp =
+                    ruleUrl.substring(start, jsMatcher.start()).trim { it <= ' ' }
+                if (tmp.isNotEmpty()) {
+                    ruleUrl = tmp.replace("@result", ruleUrl)
                 }
             }
-            result = evalJS(jsMatcher.group(2) ?: jsMatcher.group(1), result) as String
+            ruleUrl = evalJS(jsMatcher.group(2) ?: jsMatcher.group(1), ruleUrl) as String
             start = jsMatcher.end()
+            if (jsMatcher.group(0)!!.startsWith("@js:", true)) {
+                hasRule = false
+            }
         }
-        if (ruleUrl.length > start) {
-            ruleUrl.substring(start).trim().let {
-                if (it.isNotEmpty()) {
-                    result = it.replace("@result", result)
-                }
+        if (ruleUrl.length > start && hasRule) {
+            tmp = ruleUrl.substring(start).trim { it <= ' ' }
+            if (tmp.isNotEmpty()) {
+                ruleUrl = tmp.replace("@result", ruleUrl)
             }
         }
-        ruleUrl = result
     }
 
     /**