MCPcopy Index your code
hub / github.com/nodejs/node / dataURLProcessor

Function dataURLProcessor

deps/undici/undici.js:4364–4400  ·  view source on GitHub ↗
(dataURL)

Source from the content-addressed store, hash-verified

4362 var HTTP_WHITESPACE_REGEX = /[\u000A\u000D\u0009\u0020]/u;
4363 var HTTP_QUOTED_STRING_TOKENS = /^[\u0009\u0020-\u007E\u0080-\u00FF]+$/u;
4364 function dataURLProcessor(dataURL) {
4365 assert(dataURL.protocol === "data:");
4366 let input = URLSerializer(dataURL, true);
4367 input = input.slice(5);
4368 const position = { position: 0 };
4369 let mimeType = collectASequenceOfCodePointsFast(
4370 ",",
4371 input,
4372 position
4373 );
4374 const mimeTypeLength = mimeType.length;
4375 mimeType = removeASCIIWhitespace(mimeType, true, true);
4376 if (position.position >= input.length) {
4377 return "failure";
4378 }
4379 position.position++;
4380 const encodedBody = input.slice(mimeTypeLength + 1);
4381 let body = stringPercentDecode(encodedBody);
4382 if (/;(?:\u0020*)base64$/ui.test(mimeType)) {
4383 const stringBody = isomorphicDecode(body);
4384 body = forgivingBase64(stringBody);
4385 if (body === "failure") {
4386 return "failure";
4387 }
4388 mimeType = mimeType.slice(0, -6);
4389 mimeType = mimeType.replace(/(\u0020+)$/u, "");
4390 mimeType = mimeType.slice(0, -1);
4391 }
4392 if (mimeType.startsWith(";")) {
4393 mimeType = "text/plain" + mimeType;
4394 }
4395 let mimeTypeRecord = parseMIMEType(mimeType);
4396 if (mimeTypeRecord === "failure") {
4397 mimeTypeRecord = parseMIMEType("text/plain;charset=US-ASCII");
4398 }
4399 return { mimeType: mimeTypeRecord, body };
4400 }
4401 __name(dataURLProcessor, "dataURLProcessor");
4402 function URLSerializer(url, excludeFragment = false) {
4403 if (!excludeFragment) {

Callers 2

schemeFetchFunction · 0.70
test-data-url.jsFile · 0.50

Calls 10

URLSerializerFunction · 0.70
removeASCIIWhitespaceFunction · 0.70
stringPercentDecodeFunction · 0.70
isomorphicDecodeFunction · 0.70
forgivingBase64Function · 0.70
parseMIMETypeFunction · 0.70
sliceMethod · 0.65
assertFunction · 0.50
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…