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

Function bytesMatch

github-actions/browserstack/set-browserstack-env.js:4501–4530  ·  view source on GitHub ↗
(bytes, metadataList)

Source from the content-addressed store, hash-verified

4499 if (originAsURL.protocol === "https:" || originAsURL.protocol === "wss:") {
4500 return true;
4501 }
4502 if (/^127(?:\.[0-9]+){0,2}\.[0-9]+$|^\[(?:0*:)*?:?0*1\]$/.test(originAsURL.hostname) || (originAsURL.hostname === "localhost" || originAsURL.hostname.includes("localhost.")) || originAsURL.hostname.endsWith(".localhost")) {
4503 return true;
4504 }
4505 return false;
4506 }
4507 }
4508 function bytesMatch(bytes, metadataList) {
4509 if (crypto2 === void 0) {
4510 return true;
4511 }
4512 const parsedMetadata = parseMetadata(metadataList);
4513 if (parsedMetadata === "no metadata") {
4514 return true;
4515 }
4516 if (parsedMetadata.length === 0) {
4517 return true;
4518 }
4519 const strongest = getStrongestMetadata(parsedMetadata);
4520 const metadata = filterMetadataListByAlgorithm(parsedMetadata, strongest);
4521 for (const item of metadata) {
4522 const algorithm = item.algo;
4523 const expectedValue = item.hash;
4524 let actualValue = crypto2.createHash(algorithm).update(bytes).digest("base64");
4525 if (actualValue[actualValue.length - 1] === "=") {
4526 if (actualValue[actualValue.length - 2] === "=") {
4527 actualValue = actualValue.slice(0, -2);
4528 } else {
4529 actualValue = actualValue.slice(0, -1);
4530 }
4531 }
4532 if (compareBase64Mixed(actualValue, expectedValue)) {
4533 return true;

Callers 1

processBodyFunction · 0.70

Calls 6

updateMethod · 0.80
parseMetadataFunction · 0.70
getStrongestMetadataFunction · 0.70
compareBase64MixedFunction · 0.70
sliceMethod · 0.45

Tested by

no test coverage detected