forked from coolaj86/goldilocks.js
		
	fixed enclosure problem for static modules
This commit is contained in:
		
							parent
							
								
									c4af0d05ec
								
							
						
					
					
						commit
						c9318b65b0
					
				@ -355,8 +355,9 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
 | 
			
		||||
  var staticServer;
 | 
			
		||||
  var staticHandlers = {};
 | 
			
		||||
  var indexHandlers = {};
 | 
			
		||||
  function serveStatic(modOpts, req, res) {
 | 
			
		||||
  function serveStatic(req, res) {
 | 
			
		||||
    var rootDir = req.connection.rootDir;
 | 
			
		||||
    var modOpts = req.connection.modOpts;
 | 
			
		||||
 | 
			
		||||
    if (!staticHandlers[rootDir]) {
 | 
			
		||||
      staticHandlers[rootDir] = require('express').static(rootDir, {
 | 
			
		||||
@ -391,14 +392,15 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
 | 
			
		||||
        + (modOpts.view||'')
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
      if (!modOpts.indexes || ('*' !== modOpts.indexes[0] && !modOpts.indexes.some(function (pathname) {
 | 
			
		||||
      function pathMatchesUrl(pathname) {
 | 
			
		||||
        if (req.url === pathname) {
 | 
			
		||||
          return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (0 === req.url.replace(/\/?$/, '/').indexOf(pathname.replace(/\/?$/, '/'))) {
 | 
			
		||||
          return true;
 | 
			
		||||
        }
 | 
			
		||||
      }))) {
 | 
			
		||||
      }
 | 
			
		||||
      if (!modOpts.indexes || ('*' !== modOpts.indexes[0] && !modOpts.indexes.some(pathMatchesUrl))) {
 | 
			
		||||
        doFinal();
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
@ -431,11 +433,10 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!staticServer) {
 | 
			
		||||
          staticServer = require('http').createServer(function (req, res) {
 | 
			
		||||
            serveStatic(modOpts, req, res);
 | 
			
		||||
          });
 | 
			
		||||
          staticServer = require('http').createServer(serveStatic);
 | 
			
		||||
        }
 | 
			
		||||
        conn.rootDir = rootDir;
 | 
			
		||||
        conn.modOpts = modOpts;
 | 
			
		||||
        return emitConnection(staticServer, conn, opts);
 | 
			
		||||
      })
 | 
			
		||||
      .catch(function (err) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user