From d3ef9fb0327cdf7c0de41fac8a8854fc09fbf140 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 23 Nov 2015 10:22:04 +0000 Subject: [PATCH] fix wildcard bug --- lib/package-server.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/package-server.js b/lib/package-server.js index 567c42e..f17ec66 100644 --- a/lib/package-server.js +++ b/lib/package-server.js @@ -48,8 +48,6 @@ function compileVhosts(vhostsMap) { return; } - //console.log('[vhost]'); - //console.log(vhost); bare = vhost.hostname.replace(/^www\./i, ''); www = vhost.hostname.replace(/^(www\.)?/i, 'www.'); @@ -327,7 +325,11 @@ function mapToApp(opts, req, res, next) { if (!vhost) { pkgConf.vhostConf.patterns.some(function (pkg) { - if ('*' === pkg.id || pkg.id === req.hostname.slice(req.hostname.length - pkg.id.length)) { + // TODO this should be done in the compile phase + if ('*' === pkg.id[0] && '.' === pkg.id[1]) { + pkg.id = pkg.id.slice(1); + } + if (pkg.id === req.hostname.slice(req.hostname.length - pkg.id.length)) { vhost = pkg; return true; } @@ -339,9 +341,6 @@ function mapToApp(opts, req, res, next) { return; } - //console.log('vhost'); - //console.log(vhost); - // TODO don't modify route here (or in subloaders), modify some other variable instead // TODO precompile RegExps and pre-sort app vs api vhost.pathnames.some(function (routes) {