MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / dataURLProcessor

Function dataURLProcessor

out/cli.cjs:51459–51495  ·  view source on GitHub ↗
(dataURL)

Source from the content-addressed store, hash-verified

51457 "node_modules/undici/lib/fetch/dataURL.js"(exports2, module2) {
51458 var assert2 = require("assert");
51459 var { atob: atob2 } = require("buffer");
51460 var { isomorphicDecode } = require_util3();
51461 var encoder = new TextEncoder();
51462 var HTTP_TOKEN_CODEPOINTS = /^[!#$%&'*+-.^_|~A-Za-z0-9]+$/;
51463 var HTTP_WHITESPACE_REGEX = /(\u000A|\u000D|\u0009|\u0020)/;
51464 var HTTP_QUOTED_STRING_TOKENS = /[\u0009|\u0020-\u007E|\u0080-\u00FF]/;
51465 function dataURLProcessor(dataURL) {
51466 assert2(dataURL.protocol === "data:");
51467 let input = URLSerializer(dataURL, true);
51468 input = input.slice(5);
51469 const position = { position: 0 };
51470 let mimeType = collectASequenceOfCodePointsFast(
51471 ",",
51472 input,
51473 position
51474 );
51475 const mimeTypeLength = mimeType.length;
51476 mimeType = removeASCIIWhitespace(mimeType, true, true);
51477 if (position.position >= input.length) {
51478 return "failure";
51479 }
51480 position.position++;
51481 const encodedBody = input.slice(mimeTypeLength + 1);
51482 let body = stringPercentDecode(encodedBody);
51483 if (/;(\u0020){0,}base64$/i.test(mimeType)) {
51484 const stringBody = isomorphicDecode(body);
51485 body = forgivingBase64(stringBody);
51486 if (body === "failure") {
51487 return "failure";
51488 }
51489 mimeType = mimeType.slice(0, -6);
51490 mimeType = mimeType.replace(/(\u0020)+$/, "");
51491 mimeType = mimeType.slice(0, -1);
51492 }
51493 if (mimeType.startsWith(";")) {
51494 mimeType = "text/plain" + mimeType;
51495 }
51496 let mimeTypeRecord = parseMIMEType(mimeType);
51497 if (mimeTypeRecord === "failure") {
51498 mimeTypeRecord = parseMIMEType("text/plain;charset=US-ASCII");

Callers 1

schemeFetchFunction · 0.85

Calls 10

URLSerializerFunction · 0.85
removeASCIIWhitespaceFunction · 0.85
stringPercentDecodeFunction · 0.85
isomorphicDecodeFunction · 0.85
forgivingBase64Function · 0.85
parseMIMETypeFunction · 0.85
testMethod · 0.80
startsWithMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…