diff --git a/src/Analytics.js b/src/Analytics.js index 8ffce7077f..fbc8fb79c8 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -39,9 +39,17 @@ function getRedactedHash(hash) { return hash.replace(hashRegex, "#/$1"); } -// Return the current origin and hash separated with a `/`. This does not include query parameters. +// Return the current origin, path and hash separated with a `/`. This does +// not include query parameters. function getRedactedUrl() { - const { origin, pathname, hash } = window.location; + const { origin, hash } = window.location; + let { pathname } = window.location; + + // Redact paths which could contain unexpected PII + if (origin.startsWith('file://')) { + pathname = "//"; + } + return origin + pathname + getRedactedHash(hash); }