Skip to content

Commit

Permalink
simplify proxytable path segment rewrite logic
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper authored and AvianFlu committed Nov 17, 2011
1 parent 2061c71 commit c03a450
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/node-http-proxy/proxy-table.js
Expand Up @@ -138,14 +138,12 @@ ProxyTable.prototype.getProxyLocation = function (req) {
var route = this.routes[i];
if (target.match(route.route)) {

var segments = route.path.split('/');
var pathSegments = route.path.split('/');

if (segments.length > 0) {
var lastSegment = new RegExp("/" + segments[segments.length - 1] + "$");

if(req.url.match(lastSegment)) {
req.url = req.url.replace(lastSegment, '/');
}
if (pathSegments.length > 0) {
// don't include the proxytable path segments in the proxied request url
pathSegments = new RegExp("/" + pathSegments.slice(1).join('/'));
req.url = req.url.replace(pathSegments, '');
}

var location = route.target.split(':'),
Expand Down

0 comments on commit c03a450

Please sign in to comment.