Update resource-parser.js

This commit is contained in:
1nC0deWeTrust
2023-04-12 14:52:13 +08:00
committed by GitHub
parent de5a84bcce
commit 4eeb302c28

View File

@@ -1429,16 +1429,24 @@ function rule_list_handle(cnt) {
cnt = Ppolicy == "Shawn" ? cnt + ", Shawn" : cnt + ", " + Ppolicy
} else if (cnt.indexOf("payload:") == -1) { //host - suffix, not clash rule list
//$notify("xxx","xxxx",cnt)
cnt = cnt.replace(/'|"/g, "").trim()//replace(/'|"|\+\.|\*\.|\*\.\*/g,"") 2023-04-10
//clash中以.或*.开头匹配的都是子域名只存在匹配层级区别qx中有无此设计不明只能确定*可用
if (/^\.|\*\./.test(cnt)) {//以.开头 = 匹配子域名 .stun.playstation.net/*.stun.playstation.net -> *.stun.playstation.net
cnt = "host-wildcard, " + cnt.replace(/^\.|\*\./, "*.")
} else if (/^(\+\.)/.test(cnt)) {//以+.开头 = 匹配当前域名及其子域名,走后缀匹配即可 +.xboxlive.com -> suffix xboxlive.com
cnt = "host-suffix, " + cnt.replace(/^(\+\.)/, "")
} else if (cnt.indexOf("*") != -1) {//不以*.开头的字符串中包含*的情况 -> 保持该规则
cnt = "host-wildcard, " + cnt
} else {
//cnt=cnt.replace(/'|"/g,"").trim()//replace(/'|"|\+\.|\*\.|\*\.\*/g,"") 2023-04-10
if (!/^('|")/.test(cnt)) { // not clash-provider
if (!/\*|\+/.test(cnt[0])) {
cnt = cnt[0] == "." ? cnt.replace(".", "") : cnt
cnt = "host-suffix, " + cnt
} else {
cnt = "host-wildcard, " + cnt
}
} else { // clash provider
cnt = cnt.replace(/'|"/g, "").trim()
if (/^\.|\*\./.test(cnt) || cnt.indexOf("*") != -1) {
//1.以.或*.开头 -> 匹配子域名wildcard,*.domain
//2.直接替换开头,正则未匹配 -> 不以*.开头的字符串但包含*的情况(wildcard,a.*.domain...)
cnt = "host-wildcard, " + cnt.replace(/^\.|\*\./, "*.")
} else {
cnt = "host-suffix, " + cnt.replace(/^(\+\.)/, "")//如果以+.开头 = 匹配当前域名及其子域名,采用 suffix,domain。
}
}
cnt = Ppolicy == "Shawn" ? cnt + ", Shawn" : cnt + ", " + Ppolicy
}