fix: bug with case sensitive plugin and data: protocol

This commit is contained in:
alexander.akait 2023-04-13 04:01:40 +03:00
parent bb1ae43297
commit 230f830b4f
2 changed files with 15 additions and 2 deletions

View File

@ -9,6 +9,7 @@ const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./NormalModule")} NormalModule */
class WarnCaseSensitiveModulesPlugin {
/**
@ -26,8 +27,13 @@ class WarnCaseSensitiveModulesPlugin {
for (const module of compilation.modules) {
const identifier = module.identifier();
// Ignore `data:`, because it's not a real path
if (/data:/i.test(identifier)) {
// Ignore `data:` URLs, because it's not a real path
if (
/** @type {NormalModule} */
(module).resourceResolveData !== undefined &&
/** @type {NormalModule} */
(module).resourceResolveData.encodedContent !== undefined
) {
continue;
}

View File

@ -435,6 +435,8 @@ div {
div {
background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="100%25" height="100%25" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /%3E%3C/svg%3E');
background-image: url('DATA:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="100%25" height="100%25" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /%3E%3C/svg%3E');
background-image: url('DATA:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="100%25" height="100%25" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /%3E%3C/svg%3E');
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /></svg>');
background-image: url('DATA:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /></svg>');
}
@ -504,3 +506,8 @@ div {
background: url(http://example.com/image.jpg);
background: url(http://example.com/image.jpg);
}
div {
background: url('data:,');
background: url('data:,');
}