mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[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.
This commit is contained in:
parent
9f05e6c567
commit
63dfc7f175
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user