fix: suppress insecure resource warning for more local hostnames (#31035)

This commit is contained in:
trop[bot]
2021-09-21 11:29:02 +02:00
committed by GitHub
parent 221fd9d6ce
commit dfcb2afffd
3 changed files with 8 additions and 3 deletions

View File

@@ -104,10 +104,14 @@ const warnAboutInsecureResources = function () {
return;
}
const isLocal = (url: URL): boolean =>
['localhost', '127.0.0.1', '[::1]', ''].includes(url.hostname);
const isInsecure = (url: URL): boolean =>
['http:', 'ftp:'].includes(url.protocol) && !isLocal(url);
const resources = window.performance
.getEntriesByType('resource')
.filter(({ name }) => /^(http|ftp):/gi.test(name || ''))
.filter(({ name }) => new URL(name).hostname !== 'localhost')
.filter(({ name }) => isInsecure(new URL(name)))
.map(({ name }) => `- ${name}`)
.join('\n');