diff --git a/frontend/app/IFrameRoutes.tsx b/frontend/app/IFrameRoutes.tsx index bdaf1a774..0973ccd59 100644 --- a/frontend/app/IFrameRoutes.tsx +++ b/frontend/app/IFrameRoutes.tsx @@ -5,7 +5,6 @@ import { Loader } from 'UI'; import withSiteIdUpdater from 'HOCs/withSiteIdUpdater'; import * as routes from './routes'; -import { GLOBAL_HAS_NO_RECORDINGS } from 'App/constants/storageKeys'; import { Map } from 'immutable'; import NotFoundPage from 'Shared/NotFoundPage'; import { ModalProvider } from 'Components/Modal'; @@ -49,7 +48,7 @@ function IFrameRoutes(props: Props) { return ( - + }> = (props) => { const handleDestinationPath = () => { if (!isLoggedIn && location.pathname !== routes.login()) { - localStorage.setItem(GLOBAL_DESTINATION_PATH, location.pathname); + localStorage.setItem(GLOBAL_DESTINATION_PATH, location.pathname + location.search); } }; @@ -80,16 +80,25 @@ const Router: React.FC = (props) => { if ( destinationPath && destinationPath !== routes.login() && + destinationPath !== routes.signup() && destinationPath !== '/' ) { - history.push(destinationPath + location.search); + const url = new URL(destinationPath, window.location.origin); + checkParams(url.search) + history.push(destinationPath); localStorage.removeItem(GLOBAL_DESTINATION_PATH); } }; + const checkParams = (search?: string) => { + const _isIframe = checkParam('iframe', IFRAME, search); + const _isJwt = checkParam('jwt', JWT_PARAM, search); + setIsIframe(_isIframe); + setIsJwt(_isJwt); + } + useEffect(() => { - setIsIframe(checkParam('iframe', IFRAME)); - setIsJwt(checkParam('jwt', JWT_PARAM)); + checkParams(); }, []); useEffect(() => { diff --git a/frontend/app/utils/index.ts b/frontend/app/utils/index.ts index 5c95789e7..3b9f2d3ea 100644 --- a/frontend/app/utils/index.ts +++ b/frontend/app/utils/index.ts @@ -434,6 +434,7 @@ export function deleteCookie(name: string, path: string, domain: string) { * @function * @param {string} paramName - The name of the URL parameter to check. * @param {string} [storageKey] - The optional key to use for storing the result in localStorage. + * @param search * @returns {boolean} - Returns true if the parameter exists and its value is 'true'. Otherwise, returns false. * * @example @@ -448,8 +449,8 @@ export function deleteCookie(name: string, path: string, domain: string) { * does not exist, and a storageKey is provided, any existing localStorage entry with the storageKey * is removed. */ -export const checkParam = (paramName: string, storageKey?: string): boolean => { - const urlParams = new URLSearchParams(window.location.search); +export const checkParam = (paramName: string, storageKey?: string, search?: string): boolean => { + const urlParams = new URLSearchParams(search ? search : window.location.search); const paramValue = urlParams.get(paramName); const existsAndTrue = paramValue && paramValue === 'true' || paramValue?.length > 0;