Fix IPv6 localhost detection in tracker script (#1200)

IPv6 literals in url hostnames follow RFC 2732 so are enclosed in
brackets.

Browsers normalise so matching zeros is not required.

Allow `::` unspecified address as well as `::1`  loopback address.

Non-capturing groups not required when using `/.../.test()` method.
pull/1202/head
Martin Packman 5 years ago committed by GitHub
parent 0de89bad82
commit f5b412b4c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,7 +33,7 @@
function trigger(eventName, options) {
if (/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/.test(location.hostname) || location.protocol === 'file:') return warn('localhost');
if (/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(location.hostname) || location.protocol === 'file:') return warn('localhost');
if (window.phantom || window._phantom || window.__nightmare || window.navigator.webdriver || window.Cypress) return;
if (plausible_ignore=="true") return warn('localStorage flag')
{{#if exclusions}}

Loading…
Cancel
Save