X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9cd0c2757db479fb75e150d52d4871d9a88af364..3f7e1a8afad27920adf8f03ce82eeb1ae58aa84f:/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]); } };