Skip to content

Commit 5e6be6c

Browse files
mikkelindexzero
authored andcommitted
[doc] added comments to pathnameOnly block.
1 parent a1607c1 commit 5e6be6c

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

lib/node-http-proxy/proxy-table.js

+19-10
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,25 @@ ProxyTable.prototype.getProxyLocation = function (req) {
183183
else if (this.pathnameOnly === true) {
184184
var target = req.url;
185185
for (var i in this.routes) {
186-
var route = this.routes[i];
187-
if (target.match(route.source.regexp)) {
188-
req.url = url.format(target.replace(route.source.regexp, ''));
189-
return {
190-
protocol: route.target.url.protocol.replace(':', ''),
191-
host: route.target.url.hostname,
192-
port: route.target.url.port
193-
|| (this.target.https ? 443 : 80)
194-
};
195-
}
186+
var route = this.routes[i];
187+
//
188+
// If we are matching pathname only, we remove the matched pattern.
189+
//
190+
// IE /wiki/heartbeat
191+
// is redirected to
192+
// /heartbeat
193+
//
194+
// for the route "/wiki" : "127.0.0.1:8020"
195+
//
196+
if (target.match(route.source.regexp)) {
197+
req.url = url.format(target.replace(route.source.regexp, ''));
198+
return {
199+
protocol: route.target.url.protocol.replace(':', ''),
200+
host: route.target.url.hostname,
201+
port: route.target.url.port
202+
|| (this.target.https ? 443 : 80)
203+
};
204+
}
196205
}
197206

198207
}

0 commit comments

Comments
 (0)