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, response }: FetchEnd) => {
// This check does not make sense for data URI.
if (isDataURI(resource)) {
debug(`Check does not apply for data URI: ${resource}`);
return;
}
if (!willBeTreatedAsHTML(response)) {
let headersToValidate = unneededHeaders;
if (exceptionMediaTypes.includes(response.mediaType)) {
headersToValidate = mergeIgnoreIncludeArrays(headersToValidate, exceptionHeaders, []);
}
const headers = includedHeaders(response.headers, headersToValidate);
const numberOfHeaders = headers.length;
if (numberOfHeaders > 0) {
let message: string;
if (numberOfHeaders === 1) {
message = getMessage('unneededHeader', context.language, prettyPrintArray(headers));
} else {
message = getMessage('unneededHeaders', context.language, prettyPrintArray(headers));
}
context.report(resource, message, { element, severity: Severity.warning });
}
}
const loadHintConfigs = () => {
const includeHeaders = (context.hintOptions && context.hintOptions.include) || [];
const ignoreHeaders = (context.hintOptions && context.hintOptions.ignore) || [];
unneededHeaders = mergeIgnoreIncludeArrays(unneededHeaders, ignoreHeaders, includeHeaders);
};
const loadHintConfigs = () => {
includeHeaders = (context.hintOptions && context.hintOptions.include) || [];
ignoreHeaders = (context.hintOptions && context.hintOptions.ignore) || [];
disallowedHeaders = mergeIgnoreIncludeArrays(disallowedHeaders, ignoreHeaders, includeHeaders);
};