diff --git a/assets/js/p.js b/assets/js/p.js index c0a307eb2..201d3817d 100644 --- a/assets/js/p.js +++ b/assets/js/p.js @@ -57,7 +57,7 @@ } function trigger(eventName, options) { - if (/localhost$/.test(window.location.hostname)) return ignore('website is running locally'); + if (/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/.test(window.location.hostname)) return ignore('website is running locally'); if (window.location.protocol === 'file:') return ignore('website is running locally'); if (window.document.visibilityState === 'prerender') return ignore('document is prerendering'); diff --git a/assets/js/plausible.js b/assets/js/plausible.js index d7c9ef9fd..af031e150 100644 --- a/assets/js/plausible.js +++ b/assets/js/plausible.js @@ -62,7 +62,7 @@ } function trigger(eventName, options) { - if (/localhost$/.test(window.location.hostname)) return ignore('website is running locally'); + if (/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/.test(window.location.hostname)) return ignore('website is running locally'); if (window.location.protocol === 'file:') return ignore('website is running locally'); if (window.document.visibilityState === 'prerender') return ignore('document is prerendering');