diff --git a/packages/mitmproxy/src/options.js b/packages/mitmproxy/src/options.js index 3941b7e..ad07dcb 100644 --- a/packages/mitmproxy/src/options.js +++ b/packages/mitmproxy/src/options.js @@ -127,7 +127,7 @@ module.exports = (serverConfig) => { // 如果存在同名拦截器,则order值越大,优先级越高 const matchedInterceptOpt = matchInterceptsOpts[impl.name] if (matchedInterceptOpt) { - if (matchedInterceptOpt.order >= interceptOpt.order) { + if (matchedInterceptOpt.order >= (interceptOpt.order || 0)) { log.warn(`duplicate interceptor: ${impl.name}, hostname: ${rOptions.hostname}`) continue } diff --git a/packages/mitmproxy/src/utils/util.match.js b/packages/mitmproxy/src/utils/util.match.js index 0f2c00f..976f4b9 100644 --- a/packages/mitmproxy/src/utils/util.match.js +++ b/packages/mitmproxy/src/utils/util.match.js @@ -2,10 +2,16 @@ const lodash = require('lodash') const log = require('./util.log') function isMatched (url, regexp) { - if (regexp === '*') { - regexp = '.*' + try { + let urlRegexp = regexp + if (regexp[0] === '*' || regexp[0] === '?' || regexp[0] === '+') { + urlRegexp = '.' + regexp + } + return url.match(urlRegexp) + } catch (e) { + log.error('匹配串有问题:', regexp) + return false } - return url.match(regexp) } function domainRegexply (target) {