Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const validate = ({ element, resource }: ElementFound) => {
if (normalizeString(element.getAttribute('rel')) === 'manifest') {
const href = element.resolveUrl(element.getAttribute('href') || /* istanbul ignore next */ '');
const fileExtension: string = getFileExtension(normalizeString(href) || /* istanbul ignore next */ '');
if (fileExtension !== standardManifestFileExtension) {
let message: string;
let severity: Severity;
if (fileExtension) {
message = getMessage('shouldHaveFileExtensionNot', context.language, [standardManifestFileExtension, fileExtension]);
severity = fileExtension === 'json' ?
Severity.hint :
Severity.warning;
} else {
message = getMessage('shouldHaveFileExtension', context.language, standardManifestFileExtension);
severity = Severity.warning;
}
const determineMediaTypeBasedOnFileExtension = (resource: string, originalMediaType: string | null = null): string | null => {
const fileExtension = getFileExtension(resource);
if (!fileExtension) {
return null;
}
/*
* The following list is order based on the expected encounter
* rate and different statistics (e.g. for images, except `ico`,
* http://httparchive.org/interesting.php#imageformats)
*/
/*
* The reasons for hard-coding some of the values here are:
*
* * `mime-db` is quite big, so querying it is expensive.
* * `mime-db` sometimes has multiple media types for