Skip to content

Commit 96881e8

Browse files
committed
fixed bugs
1 parent bdbe1b4 commit 96881e8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

middleware.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,19 @@ module.exports = function(compiler, options) {
107107
function getFilenameFromUrl(url) {
108108
// publicPrefix is the folder our bundle should be in
109109
var localPrefix = options.publicPath || "/";
110-
if(/^https?:\/\//.test(localPrefix)) {
111-
localPrefix = "/" + localPrefix.replace(/^https?:\/\/[^\/]+\//, "");
110+
if(url.indexOf(localPrefix) !== 0) {
111+
if(/^https?:\/\//.test(localPrefix)) {
112+
localPrefix = "/" + localPrefix.replace(/^https?:\/\/[^\/]+\//, "");
113+
// fast exit if another directory requested
114+
if(url.indexOf(localPrefix) !== 0) return false;
115+
} else return false;
112116
}
113-
// fast exit if another directory requested
114-
if(url.indexOf(localPrefix) !== 0) return false;
115117
// get filename from request
116118
var filename = url.substr(localPrefix.length);
117119
if(filename.indexOf("?") >= 0) {
118120
filename = filename.substr(0, filename.indexOf("?"));
119121
}
120-
return pathJoin(compiler.outputPath, filename);
122+
return filename ? pathJoin(compiler.outputPath, filename) : compiler.outputPath;
121123
}
122124

123125
// The middleware function

0 commit comments

Comments
 (0)