MCPcopy
hub / github.com/webpack/webpack / decodeDataUriContent

Function decodeDataUriContent

lib/asset/AssetGenerator.js:186–199  ·  view source on GitHub ↗
(encoding, content)

Source from the content-addressed store, hash-verified

184 * @returns {Buffer} decoded content
185 */
186const decodeDataUriContent = (encoding, content) => {
187 const isBase64 = encoding === "base64";
188
189 if (isBase64) {
190 return Buffer.from(content, "base64");
191 }
192
193 // If we can't decode return the original body
194 try {
195 return Buffer.from(decodeURIComponent(content), "ascii");
196 } catch (_) {
197 return Buffer.from(content, "ascii");
198 }
199};
200
201const DEFAULT_ENCODING = "base64";
202

Callers 1

generateDataUriMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected