(bytes, metadataList)
| 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; |
no test coverage detected