From 4d50915373b6afaafc7857a3e9366e8e77315683 Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Fri, 14 Oct 2011 15:42:39 -0700 Subject: [PATCH] change proxytable routing to route one level shallower --- lib/node-http-proxy/proxy-table.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/node-http-proxy/proxy-table.js b/lib/node-http-proxy/proxy-table.js index 749ea7d..376d77c 100644 --- a/lib/node-http-proxy/proxy-table.js +++ b/lib/node-http-proxy/proxy-table.js @@ -101,7 +101,8 @@ ProxyTable.prototype.setRoutes = function (router) { self.routes.push({ route: route, - target: router[path] + target: router[path], + path: path }); }); } @@ -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];