fix wildcard bug
This commit is contained in:
		
							parent
							
								
									e7a6b46cc1
								
							
						
					
					
						commit
						d3ef9fb032
					
				@ -48,8 +48,6 @@ function compileVhosts(vhostsMap) {
 | 
				
			|||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //console.log('[vhost]');
 | 
					 | 
				
			||||||
    //console.log(vhost);
 | 
					 | 
				
			||||||
    bare = vhost.hostname.replace(/^www\./i, '');
 | 
					    bare = vhost.hostname.replace(/^www\./i, '');
 | 
				
			||||||
    www = vhost.hostname.replace(/^(www\.)?/i, 'www.');
 | 
					    www = vhost.hostname.replace(/^(www\.)?/i, 'www.');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -327,7 +325,11 @@ function mapToApp(opts, req, res, next) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (!vhost) {
 | 
					  if (!vhost) {
 | 
				
			||||||
    pkgConf.vhostConf.patterns.some(function (pkg) {
 | 
					    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;
 | 
					        vhost = pkg;
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -339,9 +341,6 @@ function mapToApp(opts, req, res, next) {
 | 
				
			|||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //console.log('vhost');
 | 
					 | 
				
			||||||
  //console.log(vhost);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // TODO don't modify route here (or in subloaders), modify some other variable instead
 | 
					  // TODO don't modify route here (or in subloaders), modify some other variable instead
 | 
				
			||||||
  // TODO precompile RegExps and pre-sort app vs api
 | 
					  // TODO precompile RegExps and pre-sort app vs api
 | 
				
			||||||
  vhost.pathnames.some(function (routes) {
 | 
					  vhost.pathnames.some(function (routes) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user