X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/119cee6f881abb202b9690217beba2e23d6959db..98d3f7708860701b02055643da4ba9412720bf4b:/src/common/redirect-to.ts diff --git a/src/common/redirect-to.ts b/src/common/redirect-to.ts index d8fecde4..73c94843 100644 --- a/src/common/redirect-to.ts +++ b/src/common/redirect-to.ts @@ -7,6 +7,7 @@ import { Config } from './config'; export const REDIRECT_TO_DOWNLOAD_KEY = 'redirectToDownload'; export const REDIRECT_TO_PREVIEW_KEY = 'redirectToPreview'; +export const REDIRECT_TO_KEY = 'redirectTo'; const getRedirectKeyFromUrl = (href: string): string | null => { switch (true) { @@ -14,6 +15,8 @@ const getRedirectKeyFromUrl = (href: string): string | null => { return REDIRECT_TO_DOWNLOAD_KEY; case href.indexOf(REDIRECT_TO_PREVIEW_KEY) > -1: return REDIRECT_TO_PREVIEW_KEY; + case href.indexOf(`${REDIRECT_TO_KEY}=`) > -1: + return REDIRECT_TO_KEY; default: return null; } @@ -32,8 +35,11 @@ export const storeRedirects = () => { const { location: { href }, localStorage } = window; const redirectKey = getRedirectKeyFromUrl(href); - if (localStorage && redirectKey) { - localStorage.setItem(redirectKey, href.split(`${redirectKey}=`)[1]); + // Change old redirectTo -> redirectToPreview when storing redirect + const redirectStoreKey = redirectKey === REDIRECT_TO_KEY ? REDIRECT_TO_PREVIEW_KEY : redirectKey; + + if (localStorage && redirectKey && redirectStoreKey) { + localStorage.setItem(redirectStoreKey, href.split(`${redirectKey}=`)[1]); } };