Skip to content

Commit

Permalink
[fix] In routing proxy, match line beginning
Browse files Browse the repository at this point in the history
Previous approach failed in case of routing table like:

    {
      'domain.com': 'localhost:9000',
      'a.domain.com': 'localhost:9001'
    }

without `hostnameOnly`. When routing request to `a.domain.com`,
`RegExp` matched first entry (`domain.com`) and returned it.
  • Loading branch information
mmalecki committed Dec 18, 2011
1 parent 9f05e6c commit 63dfc7f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/node-http-proxy/proxy-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ProxyTable.prototype.setRoutes = function (router) {
this.routes = [];

Object.keys(router).forEach(function (path) {
var route = new RegExp(path, 'i');
var route = new RegExp('^' + path, 'i');

self.routes.push({
route: route,
Expand Down Expand Up @@ -137,7 +137,6 @@ ProxyTable.prototype.getProxyLocation = function (req) {
for (var i in this.routes) {
var route = this.routes[i];
if (target.match(route.route)) {

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

if (pathSegments.length > 1) {
Expand Down

0 comments on commit 63dfc7f

Please sign in to comment.