bugfix: 修复拦截器匹配请求path时,部分地址匹配串在匹配时出现异常的问题,同时添加匹配串有问题的error日志。
parent
2375a30c9f
commit
24de95fa25
|
@ -127,7 +127,7 @@ module.exports = (serverConfig) => {
|
||||||
// 如果存在同名拦截器,则order值越大,优先级越高
|
// 如果存在同名拦截器,则order值越大,优先级越高
|
||||||
const matchedInterceptOpt = matchInterceptsOpts[impl.name]
|
const matchedInterceptOpt = matchInterceptsOpts[impl.name]
|
||||||
if (matchedInterceptOpt) {
|
if (matchedInterceptOpt) {
|
||||||
if (matchedInterceptOpt.order >= interceptOpt.order) {
|
if (matchedInterceptOpt.order >= (interceptOpt.order || 0)) {
|
||||||
log.warn(`duplicate interceptor: ${impl.name}, hostname: ${rOptions.hostname}`)
|
log.warn(`duplicate interceptor: ${impl.name}, hostname: ${rOptions.hostname}`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,16 @@ const lodash = require('lodash')
|
||||||
const log = require('./util.log')
|
const log = require('./util.log')
|
||||||
|
|
||||||
function isMatched (url, regexp) {
|
function isMatched (url, regexp) {
|
||||||
if (regexp === '*') {
|
try {
|
||||||
regexp = '.*'
|
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) {
|
function domainRegexply (target) {
|
||||||
|
|
Loading…
Reference in New Issue