mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-09 23:59:01 +08:00
正则表达式相关的节点操作支持使用(?i)指定忽略大小写匹配
This commit is contained in:
parent
7eed0192bc
commit
a6bf4e5c76
@ -77,9 +77,6 @@ function service() {
|
||||
// rules API
|
||||
$app.get("/download/rule/:name", downloadRule);
|
||||
|
||||
// gist backup
|
||||
$app.get("/api/backup");
|
||||
|
||||
// Storage management
|
||||
$app.route("/api/storage")
|
||||
.get((req, res) => {
|
||||
@ -1788,7 +1785,7 @@ var ProxyUtils = (function () {
|
||||
name: "Regex Sort Operator",
|
||||
func: (proxies) =>
|
||||
proxies.sort((a, b) => {
|
||||
expressions = expressions.map(expr => new RegExp(expr));
|
||||
expressions = expressions.map(expr => buildRegex(expr));
|
||||
const oA = getRegexOrder(expressions, a.name);
|
||||
const oB = getRegexOrder(expressions, b.name);
|
||||
if (oA && !oB) return -1;
|
||||
@ -1819,7 +1816,7 @@ var ProxyUtils = (function () {
|
||||
func: (proxies) => {
|
||||
return proxies.map((proxy) => {
|
||||
for (const {expr, now} of regex) {
|
||||
proxy.name = proxy.name.replace(new RegExp(expr, "g"), now).trim();
|
||||
proxy.name = proxy.name.replace(buildRegex(expr, "g"), now).trim();
|
||||
}
|
||||
return proxy;
|
||||
});
|
||||
@ -1923,8 +1920,7 @@ var ProxyUtils = (function () {
|
||||
func: (proxies) => {
|
||||
return proxies.map((proxy) => {
|
||||
const selected = regex.some((r) => {
|
||||
r = new RegExp(r);
|
||||
return r.test(proxy.name);
|
||||
return buildRegex(r).test(proxy.name);
|
||||
});
|
||||
return keep ? selected : !selected;
|
||||
});
|
||||
@ -3077,6 +3073,16 @@ function clone(object) {
|
||||
return JSON.parse(JSON.stringify(object));
|
||||
}
|
||||
|
||||
function buildRegex(str, ...options) {
|
||||
options = options.join("");
|
||||
if (str.startsWith("(?i)")) {
|
||||
str = str.substring(4);
|
||||
return new RegExp(str, 'i' + options);
|
||||
} else {
|
||||
return new RegExp(str + options);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************** Own Libraries *******************************************************/
|
||||
|
||||
|
||||
|
4
backend/sub-store.min.js
vendored
4
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user