Skip to content

fix: do not attempt to reload base64 encoded urls #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions src/hmr/hotModuleReplacement.js
Original file line number Diff line number Diff line change
@@ -90,6 +90,10 @@ function updateCss(el, url) {
url = el.href.split('?')[0];
}

if (!isUrlRequest(url)) {
return;
}

if (el.isLoaded === false) {
// We seem to be about to replace a css link that hasn't loaded yet.
// We're probably changing the same file more than once.
@@ -143,6 +147,10 @@ function reloadStyle(src) {
forEach.call(elements, function(el) {
var url = getReloadUrl(el.href, src);

if (!isUrlRequest(url)) {
return;
}

if (el.visited === true) {
return;
}
@@ -168,6 +176,27 @@ function reloadAll() {
});
}

function isUrlRequest(url) {
// An URL is not an request if

// 1. It's an absolute url
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
return false;
}

// 2. It's a protocol-relative
if (/^\/\//.test(url)) {
return false;
}

// 3. Its a `#` link
if (/^#/.test(url)) {
return false;
}

return true;
}

module.exports = function(moduleId, options) {
if (noDocument) {
console.log('no window.document found, will not HMR CSS');
@@ -179,6 +208,7 @@ module.exports = function(moduleId, options) {

function update() {
var src = getScriptSrc(options.filename);

var reloaded = reloadStyle(src);

if (options.locals) {