From 5e6be6ccf5a39ff450e57d7b24e374a83569fa85 Mon Sep 17 00:00:00 2001 From: Mikkel Garcia Date: Tue, 5 Mar 2013 17:57:03 -0700 Subject: [PATCH] [doc] added comments to pathnameOnly block. --- lib/node-http-proxy/proxy-table.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/node-http-proxy/proxy-table.js b/lib/node-http-proxy/proxy-table.js index 87184e897..407ba4739 100644 --- a/lib/node-http-proxy/proxy-table.js +++ b/lib/node-http-proxy/proxy-table.js @@ -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) + }; + } } }