From c9318b65b0540c3d8983ab118a23e3cddb36d9de Mon Sep 17 00:00:00 2001 From: tigerbot Date: Wed, 25 Oct 2017 18:06:41 -0600 Subject: [PATCH] fixed enclosure problem for static modules --- lib/modules/http.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/modules/http.js b/lib/modules/http.js index 738cdf0..547cbb8 100644 --- a/lib/modules/http.js +++ b/lib/modules/http.js @@ -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) {