From fc87c009806dcc98867f6b58efe29b042aa01dee Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 18 May 2026 23:10:59 +0800 Subject: node: update --- node_modules/webpack/lib/schemes/DataUriPlugin.js | 69 ----------------------- 1 file changed, 69 deletions(-) delete mode 100644 node_modules/webpack/lib/schemes/DataUriPlugin.js (limited to 'node_modules/webpack/lib/schemes/DataUriPlugin.js') diff --git a/node_modules/webpack/lib/schemes/DataUriPlugin.js b/node_modules/webpack/lib/schemes/DataUriPlugin.js deleted file mode 100644 index f5db88dc..00000000 --- a/node_modules/webpack/lib/schemes/DataUriPlugin.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const NormalModule = require("../NormalModule"); - -/** @typedef {import("../Compiler")} Compiler */ - -// data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string" -// http://www.ietf.org/rfc/rfc2397.txt -const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64))?,(.*)$/i; - -/** - * @param {string} uri data URI - * @returns {Buffer | null} decoded data - */ -const decodeDataURI = uri => { - const match = URIRegEx.exec(uri); - if (!match) return null; - - const isBase64 = match[3]; - const body = match[4]; - - if (isBase64) { - return Buffer.from(body, "base64"); - } - - // CSS allows to use `data:image/svg+xml;utf8,` - // so we return original body if we can't `decodeURIComponent` - try { - return Buffer.from(decodeURIComponent(body), "ascii"); - } catch (_) { - return Buffer.from(body, "ascii"); - } -}; - -class DataUriPlugin { - /** - * Apply the plugin - * @param {Compiler} compiler the compiler instance - * @returns {void} - */ - apply(compiler) { - compiler.hooks.compilation.tap( - "DataUriPlugin", - (compilation, { normalModuleFactory }) => { - normalModuleFactory.hooks.resolveForScheme - .for("data") - .tap("DataUriPlugin", resourceData => { - const match = URIRegEx.exec(resourceData.resource); - if (match) { - resourceData.data.mimetype = match[1] || ""; - resourceData.data.parameters = match[2] || ""; - resourceData.data.encoding = match[3] || false; - resourceData.data.encodedContent = match[4] || ""; - } - }); - NormalModule.getCompilationHooks(compilation) - .readResourceForScheme.for("data") - .tap("DataUriPlugin", resource => decodeDataURI(resource)); - } - ); - } -} - -module.exports = DataUriPlugin; -- cgit v1.2.3