From 75558dcfa836a7eb4ec2c3eed8f799c6a0e2cf9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Wed, 23 Oct 2024 13:55:03 +0200 Subject: [PATCH] Update index.tsx --- .../ui/src/components/App/index.tsx | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/verification/curator-service/ui/src/components/App/index.tsx b/verification/curator-service/ui/src/components/App/index.tsx index dd1eecaab..465fcf8db 100644 --- a/verification/curator-service/ui/src/components/App/index.tsx +++ b/verification/curator-service/ui/src/components/App/index.tsx @@ -327,14 +327,7 @@ export default function App(): JSX.Element { }; const onModalClose = (): void => { - let parsedSearchQuery: string = ''; - if (searchQuery.includes('?q=')) { - parsedSearchQuery = `?q=${encodeURIComponent(searchQuery.split('?q=')[1])}`; - } else if (searchQuery.includes('&q=')) { - parsedSearchQuery = `${searchQuery.split('&q=')[0]}&q=${encodeURIComponent(searchQuery.split('&q=')[1])}`; - } else { - parsedSearchQuery = searchQuery; - } + const searchQueryObject = new URLSearchParams(searchQuery); navigate( { @@ -342,7 +335,7 @@ export default function App(): JSX.Element { location.state && location.state.lastLocation ? location.state.lastLocation : '/cases', - search: parsedSearchQuery, + search: searchQueryObject.toString(), }, { state: { lastLocation: '/case/view' } }, ); @@ -380,7 +373,8 @@ export default function App(): JSX.Element { ) return; - dispatch(setSearchQuery(decodeURIComponent(location.search))); + const searchParams = new URLSearchParams(location.search); + dispatch(setSearchQuery(searchParams.toString())); // Save searchQuery to local storage not to lost it when user goes through auth process localStorage.setItem('searchQuery', location.search);