- const { keepWebServiceUrl } = config;
-
- if (localStorage && localStorage.getItem(REDIRECT_TO_KEY)) {
- const redirectUrl = localStorage.getItem(REDIRECT_TO_KEY);
- localStorage.removeItem(REDIRECT_TO_KEY);
- const applyToPath = localStorage.getItem(REDIRECT_TO_APPLY_TO_PATH);
-
- if (redirectUrl) {
- if (applyToPath === 'true') {
- localStorage.removeItem(REDIRECT_TO_APPLY_TO_PATH);
- setTimeout(() => {
- window.location.pathname = redirectUrl;
- }, 0);
- } else {
- const sep = redirectUrl.indexOf("?") > -1 ? "&" : "?";
- window.location.href = `${keepWebServiceUrl}${redirectUrl}${sep}api_token=${token}`;
+ const { keepWebServiceUrl, keepWebInlineServiceUrl } = config;
+
+ if (localStorage) {
+ const redirectKey = getRedirectKeyFromStorage(localStorage);
+ const redirectPath = redirectKey ? localStorage.getItem(redirectKey) : '';
+ redirectKey && localStorage.removeItem(redirectKey);
+
+ if (redirectKey && redirectPath) {
+ const sep = redirectPath.indexOf("?") > -1 ? "&" : "?";
+ let redirectUrl = `${keepWebServiceUrl}${redirectPath}${sep}api_token=${token}`;
+ if (redirectKey === REDIRECT_TO_PREVIEW_KEY) {
+ redirectUrl = getInlineFileUrl(redirectUrl, keepWebServiceUrl, keepWebInlineServiceUrl);