Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async fetchManifest(elementFound: ElementFound) {
const { element, resource } = elementFound;
/*
* Check if the target is a local file, and if it is,
* don't try to fetch the web app manifest file as it's
* `href` value will most probably not map to anything
* on disk and the request will fail.
*
* TODO: Remove this once things work as expected.
*/
if (!isHTTP(resource) && !isHTTPS(resource)) {
return;
}
// Check if the `link` tag is for the web app manifest.
if (normalizeString(element.getAttribute('rel')) !== 'manifest') {
return;
}
// If so, check if a non-empty `href` was specified.
const hrefValue: string | null = normalizeString(element.getAttribute('href'));
if (!hrefValue) {
return;
}
resource,
getMessage('couldNotBeFetchedBrotli', context.language),
{ element, severity: Severity.error }
);
return;
}
const { contentEncodingHeaderValue, rawResponse, response } = networkData;
const compressedWithBrotli = await isCompressedWithBrotli(rawResponse);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Check if compressed with Brotli over HTTP.
if (isHTTP(resource)) {
if (compressedWithBrotli) {
context.report(
resource,
getMessage('noCompressedBrotliOverHTTP', context.language),
{ element, severity: Severity.warning }
);
}
return;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Check compressed vs. uncompressed sizes.
/*