匹配方法优化。

pull/375/head
王良 2024-09-28 22:37:23 +08:00
parent 457a3b6ae3
commit ed52dafeb3
1 changed files with 5 additions and 1 deletions

View File

@ -2,6 +2,10 @@ const lodash = require('lodash')
const log = require('./util.log')
function isMatched (url, regexp) {
if (regexp === true || regexp === 'true') {
return true
}
try {
let urlRegexp = regexp
if (regexp[0] === '*' || regexp[0] === '?' || regexp[0] === '+') {
@ -15,7 +19,7 @@ function isMatched (url, regexp) {
}
function domainRegexply (target) {
if (target === '.*') {
if (target === '.*' || target === '*' || target === 'true') {
return '^.*$'
}
return '^' + target.replace(/\./g, '\\.').replace(/\*/g, '.*') + '$'