Skip to content

Commit 64a0e4d

Browse files
committed
Merge pull request #6 from unfold/patch-1
Fix invalid next() invocation in filename resolver.
2 parents ae0b1e5 + 438652d commit 64a0e4d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

middleware.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function(compiler, options) {
1111
if(!options) options = {};
1212
if(options.watchDelay === undefined) options.watchDelay = 200;
1313
if(!options.stats) options.stats = {};
14-
if(!options.stats.context === undefined) options.stats.context = process.cwd();
14+
if(options.stats.context !== undefined) options.stats.context = process.cwd();
1515

1616
// store our files in memory
1717
var files = {};
@@ -111,7 +111,7 @@ module.exports = function(compiler, options) {
111111
localPrefix = "/" + localPrefix.replace(/^https?:\/\/[^\/]+\//, "");
112112
}
113113
// fast exit if another directory requested
114-
if(url.indexOf(localPrefix) != 0) return next();
114+
if(url.indexOf(localPrefix) !== 0) return false;
115115
// get filename from request
116116
var filename = url.substr(localPrefix.length);
117117
return pathJoin(compiler.outputPath, filename);
@@ -120,6 +120,8 @@ module.exports = function(compiler, options) {
120120
// The middleware function
121121
function webpackDevMiddleware(req, res, next) {
122122
var filename = getFilenameFromUrl(req.url);
123+
if (filename === false) return next();
124+
123125
// in lazy mode, rebuild on bundle request
124126
if(options.lazy && filename === pathJoin(compiler.outputPath, options.filename))
125127
rebuild();
@@ -154,4 +156,4 @@ module.exports = function(compiler, options) {
154156
webpackDevMiddleware.fileSystem = fs;
155157

156158
return webpackDevMiddleware;
157-
}
159+
}

0 commit comments

Comments
 (0)