Skip to content

Commit

Permalink
Support query strings on HMR event stream url
Browse files Browse the repository at this point in the history
This allows use of common EventSource polyfills
  • Loading branch information
glenjamin committed Sep 19, 2015
1 parent 2f58a8a commit 649332d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function webpackHotMiddleware(compiler, opts) {
});
});
return function(req, res, next) {
if (req.url !== opts.path) return next();
if (!pathMatch(req.url, opts.path)) return next();
eventStream.handler(req, res);
};
}
Expand Down Expand Up @@ -68,6 +68,13 @@ function createEventStream(heartbeat) {
};
}

function pathMatch(url, path) {
if (url == path) return true;
var q = url.indexOf('?');
if (q == -1) return false;
return url.substring(0, q) == path;
}

function buildModuleMap(modules) {
var map = {};
modules.forEach(function(module) {
Expand Down

0 comments on commit 649332d

Please sign in to comment.