Skip to content

Commit

Permalink
bugfix: 修复拦截器匹配请求path时,部分地址匹配串在匹配时出现异常的问题,同时添加匹配串有问题的error日志。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Sep 13, 2024
1 parent 2375a30 commit 24de95f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/mitmproxy/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 9 additions & 3 deletions packages/mitmproxy/src/utils/util.match.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 24de95f

Please sign in to comment.