Commit 8aac243b authored by Maciej Małecki's avatar Maciej Małecki Committed by Cédric de Saint Martin

[fix] In routing proxy, match line beginning

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.
parent cf39e55a
......@@ -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,
......@@ -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) {
......
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