mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[doc] added comments to pathnameOnly block.
This commit is contained in:
parent
a1607c1684
commit
5e6be6ccf5
@ -183,16 +183,25 @@ ProxyTable.prototype.getProxyLocation = function (req) {
|
||||
else if (this.pathnameOnly === true) {
|
||||
var target = req.url;
|
||||
for (var i in this.routes) {
|
||||
var route = this.routes[i];
|
||||
if (target.match(route.source.regexp)) {
|
||||
req.url = url.format(target.replace(route.source.regexp, ''));
|
||||
return {
|
||||
protocol: route.target.url.protocol.replace(':', ''),
|
||||
host: route.target.url.hostname,
|
||||
port: route.target.url.port
|
||||
|| (this.target.https ? 443 : 80)
|
||||
};
|
||||
}
|
||||
var route = this.routes[i];
|
||||
//
|
||||
// If we are matching pathname only, we remove the matched pattern.
|
||||
//
|
||||
// IE /wiki/heartbeat
|
||||
// is redirected to
|
||||
// /heartbeat
|
||||
//
|
||||
// for the route "/wiki" : "127.0.0.1:8020"
|
||||
//
|
||||
if (target.match(route.source.regexp)) {
|
||||
req.url = url.format(target.replace(route.source.regexp, ''));
|
||||
return {
|
||||
protocol: route.target.url.protocol.replace(':', ''),
|
||||
host: route.target.url.hostname,
|
||||
port: route.target.url.port
|
||||
|| (this.target.https ? 443 : 80)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user