Skip to content

Commit

Permalink
change proxytable routing to route one level shallower
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper committed Oct 14, 2011
1 parent f188f4f commit 4d50915
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/node-http-proxy/proxy-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ ProxyTable.prototype.setRoutes = function (router) {

self.routes.push({
route: route,
target: router[path]
target: router[path],
path: path
});
});
}
Expand Down Expand Up @@ -138,6 +139,14 @@ ProxyTable.prototype.getProxyLocation = function (req) {
match;

if (match = target.match(route.route)) {

var root = "/" + route.path.split('/')[1];
var beginningSegment = new RegExp("^" + root);

if(req.url.match(beginningSegment)) {
req.url = req.url.replace(beginningSegment, '');
}

var location = route.target.split(':'),
host = location[0],
port = location.length === 1 ? 80 : location[1];
Expand Down

0 comments on commit 4d50915

Please sign in to comment.