MCPcopy Create free account
hub / github.com/angular/dev-infra / forgivingBase64

Function forgivingBase64

github-actions/saucelabs/set-saucelabs-env.js:3633–3652  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

3631 continue;
3632 }
3633 }
3634 if (parameterName.length !== 0 && HTTP_TOKEN_CODEPOINTS.test(parameterName) && (parameterValue.length === 0 || HTTP_QUOTED_STRING_TOKENS.test(parameterValue)) && !mimeType.parameters.has(parameterName)) {
3635 mimeType.parameters.set(parameterName, parameterValue);
3636 }
3637 }
3638 return mimeType;
3639 }
3640 function forgivingBase64(data) {
3641 data = data.replace(ASCII_WHITESPACE_REPLACE_REGEX, "");
3642 let dataLength = data.length;
3643 if (dataLength % 4 === 0) {
3644 if (data.charCodeAt(dataLength - 1) === 61) {
3645 --dataLength;
3646 if (data.charCodeAt(dataLength - 1) === 61) {
3647 --dataLength;
3648 }
3649 }
3650 }
3651 if (dataLength % 4 === 1) {
3652 return "failure";
3653 }
3654 if (/[^+/0-9A-Za-z]/.test(data.length === dataLength ? data : data.substring(0, dataLength))) {
3655 return "failure";

Callers 1

dataURLProcessorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected