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E,UAAS,SAAU,cAAc,SAAS,SAClF,CACJ,IAIR,EAEJ,QAAQ,QAAU,sBAClB,sBAAsB,KAAO,OAAO","file":"/npm/@hint/hint-no-html-only-headers@3.0.23/dist/src/hint.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/@hint/hint-no-html-only-headers@3.0.23/dist/src/hint.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst utils_debug_1 = require(\"@hint/utils-debug\");\nconst utils_network_1 = require(\"@hint/utils-network\");\nconst utils_string_1 = require(\"@hint/utils-string\");\nconst utils_types_1 = require(\"@hint/utils-types\");\nconst meta_1 = require(\"./meta\");\nconst i18n_import_1 = require(\"./i18n.import\");\nconst debug = (0, utils_debug_1.debug)(__filename);\nclass NoHtmlOnlyHeadersHint {\n    constructor(context) {\n        let unneededHeaders = [\n            'content-security-policy',\n            'feature-policy',\n            'x-content-security-policy',\n            'x-ua-compatible',\n            'x-webkit-csp',\n            'x-xss-protection'\n        ];\n        const exceptionHeaders = [\n            'content-security-policy',\n            'x-content-security-policy',\n            'x-webkit-csp'\n        ];\n        const exceptionMediaTypes = [\n            'application/pdf',\n            'image/svg+xml',\n            'text/javascript'\n        ];\n        const loadHintConfigs = () => {\n            const includeHeaders = (context.hintOptions && context.hintOptions.include) || [];\n            const ignoreHeaders = (context.hintOptions && context.hintOptions.ignore) || [];\n            unneededHeaders = (0, utils_string_1.mergeIgnoreIncludeArrays)(unneededHeaders, ignoreHeaders, includeHeaders);\n        };\n        const willBeTreatedAsHTML = (response) => {\n            const contentTypeHeader = response.headers['content-type'];\n            const mediaType = contentTypeHeader ? contentTypeHeader.split(';')[0].trim() : '';\n            if ([\n                'text/html',\n                'text/xml',\n                'application/xhtml+xml'\n            ].includes(mediaType)) {\n                return true;\n            }\n            if (mediaType.indexOf('/') > 0) {\n                return false;\n            }\n            return false;\n        };\n        const validate = ({ element, resource, response }) => {\n            if ((0, utils_network_1.isDataURI)(resource)) {\n                debug(`Check does not apply for data URI: ${resource}`);\n                return;\n            }\n            if (!willBeTreatedAsHTML(response)) {\n                let headersToValidate = unneededHeaders;\n                if (exceptionMediaTypes.includes(response.mediaType)) {\n                    headersToValidate = (0, utils_string_1.mergeIgnoreIncludeArrays)(headersToValidate, exceptionHeaders, []);\n                }\n                const headers = (0, utils_network_1.includedHeaders)(response.headers, headersToValidate);\n                const numberOfHeaders = headers.length;\n                if (numberOfHeaders > 0) {\n                    const message = (0, i18n_import_1.getMessage)('unneededHeaders', context.language, headers.join(', '));\n                    context.report(resource, message, { element, severity: utils_types_1.Severity.warning });\n                }\n            }\n        };\n        loadHintConfigs();\n        context.on('fetch::end::*', validate);\n    }\n}\nexports.default = NoHtmlOnlyHeadersHint;\nNoHtmlOnlyHeadersHint.meta = meta_1.default;\n"]}