From 19e948155c8957094430d4af9c10dcbc93502c4e Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 26 Jun 2018 17:06:12 +0100 Subject: [PATCH 1/2] Redact pathnames with origin `file://` --- src/Analytics.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Analytics.js b/src/Analytics.js index 8ffce7077f..41eaca0f63 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -39,9 +39,16 @@ 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; + + // Redact paths which could contain unexpected PII + if (origin.startsWith('file://')) { + pathname = "//"; + } + return origin + pathname + getRedactedHash(hash); } From 483edb821106bda1579dbf44bd556ffe4acbaacb Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 27 Jun 2018 10:31:51 +0100 Subject: [PATCH 2/2] `pathname` is not constant --- src/Analytics.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Analytics.js b/src/Analytics.js index 41eaca0f63..fbc8fb79c8 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -42,7 +42,8 @@ function getRedactedHash(hash) { // 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://')) {