Commit c03a450d authored by Max Ogden's avatar Max Ogden Committed by Charlie McConnell

simplify proxytable path segment rewrite logic

parent 2061c713
...@@ -138,14 +138,12 @@ ProxyTable.prototype.getProxyLocation = function (req) { ...@@ -138,14 +138,12 @@ ProxyTable.prototype.getProxyLocation = function (req) {
var route = this.routes[i]; var route = this.routes[i];
if (target.match(route.route)) { if (target.match(route.route)) {
var segments = route.path.split('/'); var pathSegments = route.path.split('/');
if (segments.length > 0) { if (pathSegments.length > 0) {
var lastSegment = new RegExp("/" + segments[segments.length - 1] + "$"); // don't include the proxytable path segments in the proxied request url
pathSegments = new RegExp("/" + pathSegments.slice(1).join('/'));
if(req.url.match(lastSegment)) { req.url = req.url.replace(pathSegments, '');
req.url = req.url.replace(lastSegment, '/');
}
} }
var location = route.target.split(':'), var location = route.target.split(':'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment