From 0d6c5d8cea265ebc6a531c59ffe84e0334810496 Mon Sep 17 00:00:00 2001 From: internxt-yu Date: Fri, 3 Jul 2026 12:53:31 +0200 Subject: [PATCH 1/4] clear the parameters of google analytics and google tags manager in url section --- src/App.tsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 90358e0..4255933 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,6 +5,7 @@ import { FilesProvider } from './contexts/Files'; import DownloadView from './views/DownloadView'; import HomeView from './views/HomeView'; import NotFoundView from './views/NotFoundView'; +import { useEffect } from 'react'; function DownloadRedirectWrapper() { const { sendId } = useParams(); @@ -15,6 +16,27 @@ function DownloadRedirectWrapper() { } function App() { + useEffect(() => { + const url = new URL(window.location.href); + const parametersToClear = ['_gl', '_gcl_au', '_ga']; + let hadChanges = false; + + parametersToClear.forEach((param) => { + if (url.searchParams.has(param)) { + url.searchParams.delete(param); + hadChanges = true; + } + }); + + if (hadChanges) { + const newUrl = url.searchParams.toString() + ? `${url.pathname}?${url.searchParams.toString()}${url.hash}` + : `${url.pathname}${url.hash}`; + + window.history.replaceState({}, document.title, newUrl); + } + }, []); + return ( <> From d6764c0dc983961a4fc2348fbc487eadd94a7dbf Mon Sep 17 00:00:00 2001 From: internxt-yu Date: Fri, 3 Jul 2026 15:17:57 +0200 Subject: [PATCH 2/4] fix: clears parameters starts with _ga and parameter _fplc --- src/App.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 4255933..df35b90 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -18,11 +18,12 @@ function DownloadRedirectWrapper() { function App() { useEffect(() => { const url = new URL(window.location.href); - const parametersToClear = ['_gl', '_gcl_au', '_ga']; let hadChanges = false; - parametersToClear.forEach((param) => { - if (url.searchParams.has(param)) { + const currentKeys = Array.from(url.searchParams.keys()); + + currentKeys.forEach((param) => { + if (param === '_gl' || param === '_gcl_au' || param === '_fplc' || param.startsWith('_ga')) { url.searchParams.delete(param); hadChanges = true; } From 57abcaac3c87fee99717b6cbc9626c07659e4975 Mon Sep 17 00:00:00 2001 From: internxt-yu Date: Mon, 6 Jul 2026 13:14:41 +0200 Subject: [PATCH 3/4] extract the funtion cleanUrlParam from app.tsx --- src/App.tsx | 24 ++---------------------- src/utils/cleanUrl.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 src/utils/cleanUrl.ts diff --git a/src/App.tsx b/src/App.tsx index df35b90..0775582 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,7 +5,7 @@ import { FilesProvider } from './contexts/Files'; import DownloadView from './views/DownloadView'; import HomeView from './views/HomeView'; import NotFoundView from './views/NotFoundView'; -import { useEffect } from 'react'; +import { cleanUrlParam } from './utils/cleanUrl'; function DownloadRedirectWrapper() { const { sendId } = useParams(); @@ -16,27 +16,7 @@ function DownloadRedirectWrapper() { } function App() { - useEffect(() => { - const url = new URL(window.location.href); - let hadChanges = false; - - const currentKeys = Array.from(url.searchParams.keys()); - - currentKeys.forEach((param) => { - if (param === '_gl' || param === '_gcl_au' || param === '_fplc' || param.startsWith('_ga')) { - url.searchParams.delete(param); - hadChanges = true; - } - }); - - if (hadChanges) { - const newUrl = url.searchParams.toString() - ? `${url.pathname}?${url.searchParams.toString()}${url.hash}` - : `${url.pathname}${url.hash}`; - - window.history.replaceState({}, document.title, newUrl); - } - }, []); + cleanUrlParam(); return ( <> diff --git a/src/utils/cleanUrl.ts b/src/utils/cleanUrl.ts new file mode 100644 index 0000000..47db08a --- /dev/null +++ b/src/utils/cleanUrl.ts @@ -0,0 +1,30 @@ +import { useEffect } from 'react'; + +/** + * Remove Google Analytics/Tag Manager tracking query parameters + * to keep the URL looking clean for the users after page has loaded + */ + +export function cleanUrlParam() { + useEffect(() => { + const url = new URL(window.location.href); + let hadChanges = false; + + const currentKeys = Array.from(url.searchParams.keys()); + + currentKeys.forEach((param) => { + if (param === '_gl' || param === '_gcl_au' || param === '_fplc' || param.startsWith('_ga')) { + url.searchParams.delete(param); + hadChanges = true; + } + }); + + if (hadChanges) { + const newUrl = url.searchParams.toString() + ? `${url.pathname}?${url.searchParams.toString()}${url.hash}` + : `${url.pathname}${url.hash}`; + + window.history.replaceState({}, document.title, newUrl); + } + }, []); +} From ad8d21491ea18e2eda1e1ff58bf83a5a14f3cbf4 Mon Sep 17 00:00:00 2001 From: internxt-yu Date: Mon, 6 Jul 2026 15:47:57 +0200 Subject: [PATCH 4/4] refactor: separate URL cleanup logic from React effect --- src/App.tsx | 5 ++++- src/utils/cleanUrl.ts | 34 +++++++++++++++------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 0775582..3eae1bd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,6 +5,7 @@ import { FilesProvider } from './contexts/Files'; import DownloadView from './views/DownloadView'; import HomeView from './views/HomeView'; import NotFoundView from './views/NotFoundView'; +import { useEffect } from 'react'; import { cleanUrlParam } from './utils/cleanUrl'; function DownloadRedirectWrapper() { @@ -16,7 +17,9 @@ function DownloadRedirectWrapper() { } function App() { - cleanUrlParam(); + useEffect(() => { + cleanUrlParam(); + }, []); return ( <> diff --git a/src/utils/cleanUrl.ts b/src/utils/cleanUrl.ts index 47db08a..a547a9d 100644 --- a/src/utils/cleanUrl.ts +++ b/src/utils/cleanUrl.ts @@ -1,30 +1,26 @@ -import { useEffect } from 'react'; - /** * Remove Google Analytics/Tag Manager tracking query parameters * to keep the URL looking clean for the users after page has loaded */ export function cleanUrlParam() { - useEffect(() => { - const url = new URL(window.location.href); - let hadChanges = false; + const url = new URL(window.location.href); + let hadChanges = false; - const currentKeys = Array.from(url.searchParams.keys()); + const currentKeys = Array.from(url.searchParams.keys()); - currentKeys.forEach((param) => { - if (param === '_gl' || param === '_gcl_au' || param === '_fplc' || param.startsWith('_ga')) { - url.searchParams.delete(param); - hadChanges = true; - } - }); + currentKeys.forEach((param) => { + if (param === '_gl' || param === '_gcl_au' || param === '_fplc' || param.startsWith('_ga')) { + url.searchParams.delete(param); + hadChanges = true; + } + }); - if (hadChanges) { - const newUrl = url.searchParams.toString() - ? `${url.pathname}?${url.searchParams.toString()}${url.hash}` - : `${url.pathname}${url.hash}`; + if (hadChanges) { + const newUrl = url.searchParams.toString() + ? `${url.pathname}?${url.searchParams.toString()}${url.hash}` + : `${url.pathname}${url.hash}`; - window.history.replaceState({}, document.title, newUrl); - } - }, []); + window.history.replaceState({}, document.title, newUrl); + } }