This commit is contained in:
xiaofeng.mxf 2020-01-01 19:32:30 +08:00
parent 7c2a161c0a
commit 1e8b61ac77

View File

@ -223,7 +223,15 @@ function getUserReqHandler(userRule, recorder) {
const host = req.headers.host; const host = req.headers.host;
const protocol = (!!req.connection.encrypted && !(/^http:/).test(req.url)) ? 'https' : 'http'; 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 urlPattern = url.parse(fullUrl);
const path = urlPattern.path; const path = urlPattern.path;