diff --git a/components/WebsiteDetails.js b/components/WebsiteDetails.js index a5c27f35..4d91b7bb 100644 --- a/components/WebsiteDetails.js +++ b/components/WebsiteDetails.js @@ -77,7 +77,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' }) websiteId={websiteId} startDate={startDate} endDate={endDate} - dataFilter={refFilter} + dataFilter={refFilter(data.domain)} /> diff --git a/components/interface/UserButton.js b/components/interface/UserButton.js index 551c452c..dec8f37f 100644 --- a/components/interface/UserButton.js +++ b/components/interface/UserButton.js @@ -47,7 +47,7 @@ export default function UserButton() { return (
setShowMenu(state => !state)}> - } size="L" className={styles.icon} /> + } size="L" /> } size="S" />
{showMenu && } diff --git a/components/interface/UserButton.module.css b/components/interface/UserButton.module.css index bdb0daa5..20b33d22 100644 --- a/components/interface/UserButton.module.css +++ b/components/interface/UserButton.module.css @@ -4,10 +4,6 @@ cursor: pointer; } -.icon { - margin-right: 8px; -} - .username { border-bottom: 1px solid var(--gray500); } diff --git a/lib/filters.js b/lib/filters.js index ed4c038a..a8283df7 100644 --- a/lib/filters.js +++ b/lib/filters.js @@ -1,3 +1,4 @@ +import escape from 'escape-string-regexp'; import { BROWSERS, ISO_COUNTRIES, DEVICES } from './constants'; export const browserFilter = data => @@ -5,8 +6,12 @@ export const browserFilter = data => export const urlFilter = data => data.filter(({ x }) => x !== '' && !x.startsWith('#')); -export const refFilter = data => - data.filter(({ x }) => x !== '' && !x.startsWith('/') && !x.startsWith('#')); +export const refFilter = domain => data => { + const regex = new RegExp(escape(domain)); + return data.filter( + ({ x }) => x !== '' && !x.startsWith('/') && !x.startsWith('#') && !regex.test(x), + ); +}; export const deviceFilter = data => data.map(({ x, ...props }) => ({ x: DEVICES[x] || x, ...props })); diff --git a/package.json b/package.json index 0ad526ff..6e47fa4a 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "date-fns-tz": "^1.0.10", "detect-browser": "^5.1.1", "dotenv": "^8.2.0", + "escape-string-regexp": "^4.0.0", "formik": "^2.1.5", "geolite2-redist": "^1.0.7", "is-localhost-ip": "^1.4.0", diff --git a/yarn.lock b/yarn.lock index 2743d66f..e4c17eea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3605,6 +3605,11 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + eslint-config-prettier@^6.11.0: version "6.11.0" resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz#f6d2238c1290d01c859a8b5c1f7d352a0b0da8b1"