Updated rule

pull/32/head
atbest 6 years ago
parent 500363a1a7
commit a6c0acf07f
  1. 6
      app/src/main/java/io/legado/app/data/entities/rule/Rule.kt

@ -10,8 +10,8 @@ data class Rule (
var extra: String? var extra: String?
) { ) {
companion object { companion object {
val JS_PATTERN = Regex("""\{\{([^}]+?)\}\}""") val JS_PATTERN = Regex("""\{\{([^}]+?)}}""")
val CONST_PATTERN = Regex("""\{(\$\.[^}]+?)\}""") val CONST_PATTERN = Regex("""\{(\$\.[^}]+?)}""")
fun parse(input: String) = when { fun parse(input: String) = when {
input.startsWith("$.") -> parseJSON(input) input.startsWith("$.") -> parseJSON(input)
@ -69,7 +69,7 @@ data class Rule (
for (line in rawRule.splitNotBlank("\n")) { for (line in rawRule.splitNotBlank("\n")) {
subRule.clear() subRule.clear()
val baseRule = BaseRule(type = RuleType.JSON) val baseRule = BaseRule(type = RuleType.JSON)
baseRule.template = CONST_PATTERN.replace(line) { match -> baseRule.template = CONST_PATTERN.replace(line.replace("%", "%%")) { match ->
subRule.add(match.groupValues[1]) subRule.add(match.groupValues[1])
"%s" "%s"
} }

Loading…
Cancel
Save