From 649332d12028f9c84cf7c68e47ad65ef53a8aca6 Mon Sep 17 00:00:00 2001 From: Glen Mailer Date: Sat, 19 Sep 2015 16:21:17 +0100 Subject: [PATCH] Support query strings on HMR event stream url This allows use of common EventSource polyfills --- middleware.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/middleware.js b/middleware.js index 9aa9d39..96f900a 100644 --- a/middleware.js +++ b/middleware.js @@ -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); }; } @@ -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) {