Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix IPv6 localhost detection in tracker script (#1200)

Martin Packmanf5b412b4c8ab
diff --git a/tracker/src/plausible.js b/tracker/src/plausible.js
index 7c7d960fd2..f1a58cb928 100644
--- a/tracker/src/plausible.js
+++ b/tracker/src/plausible.js
@@ -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}}