优化是否绝对地址的判断。

pull/295/head
王良 2024-04-13 23:11:04 +08:00
parent 6062ace926
commit 698029c001
2 changed files with 2 additions and 2 deletions

View File

@ -33,7 +33,7 @@ function buildTargetUrl (rOptions, urlConf, interceptOpt, matched) {
targetUrl = urlConf
} else {
let uri = rOptions.path
if (uri.indexOf('http') === 0) {
if (uri.indexOf('http:') === 0 || uri.indexOf('https:') === 0) {
// eslint-disable-next-line node/no-deprecated-api
const URL = url.parse(uri)
uri = URL.path

View File

@ -83,7 +83,7 @@ module.exports = function createOverWallIntercept (overWallConfig) {
const proxyTarget = domain + '/' + path + '/' + hostname + req.url
// const backup = interceptOpt.backup
const proxy = proxyTarget.indexOf('http') === 0 ? proxyTarget : (rOptions.protocol + '//' + proxyTarget)
const proxy = proxyTarget.indexOf('http:') === 0 || proxyTarget.indexOf('https:') === 0 ? proxyTarget : (rOptions.protocol + '//' + proxyTarget)
// eslint-disable-next-line node/no-deprecated-api
const URL = url.parse(proxy)
rOptions.origional = lodash.cloneDeep(rOptions) // 备份原始请求参数