diff --git a/lib/requestHandler.js b/lib/requestHandler.js index 0f8c3f7..03067ce 100644 --- a/lib/requestHandler.js +++ b/lib/requestHandler.js @@ -272,7 +272,15 @@ function getUserReqHandler(userRule, recorder) { const host = req.headers.host; const protocol = (!!req.connection.encrypted && !(/^http:/).test(req.url)) ? 'https' : 'http'; - const fullUrl = protocol === 'http' ? req.url : (protocol + '://' + host + req.url); + + // try find fullurl https://github.com/alibaba/anyproxy/issues/419 + let fullUrl = protocol + '://' + host + req.url; + if (protocol === 'http') { + const reqUrlPattern = url.parse(req.url); + if (reqUrlPattern.host && reqUrlPattern.protocol) { + fullUrl = req.url; + } + } const urlPattern = url.parse(fullUrl); const path = urlPattern.path;