Skip to content

Commit

Permalink
[doc] added comments to pathnameOnly block.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkel authored and indexzero committed Mar 9, 2013
1 parent a1607c1 commit 5e6be6c
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions lib/node-http-proxy/proxy-table.js
Expand Up @@ -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)
};
}
}

}
Expand Down

0 comments on commit 5e6be6c

Please sign in to comment.