diff --git a/blocks/edit/prose/index.js b/blocks/edit/prose/index.js index 4ee9d5673..ba57897d1 100644 --- a/blocks/edit/prose/index.js +++ b/blocks/edit/prose/index.js @@ -260,7 +260,11 @@ function handleAwarenessUpdates(wsProvider, daTitle, win, path) { wsProvider.on('connection-close', async () => { const resp = await checkDoc(path); if (resp.status === 404) { - const split = window.location.hash.slice(2).split('/'); + const { hash } = window.location; + // Guard: hash must start with '#/' — during an IMS redirect the hash is '#access_token=...' + // and slice(2) would remove '#a', writing 'ccess_token=...' into the URL as an org name. + if (!hash.startsWith('#/')) return; + const split = hash.slice(2).split('/'); split.pop(); // Navigate to the parent folder window.location.replace(`/#/${split.join('/')}`); diff --git a/blocks/shared/pathDetails.js b/blocks/shared/pathDetails.js index d72e53594..1ff750d7f 100644 --- a/blocks/shared/pathDetails.js +++ b/blocks/shared/pathDetails.js @@ -123,8 +123,10 @@ export default function getPathDetails(loc) { // config, edit, sheet const editor = getView(pathname); - // IMS will redirect and there's a small window where old_hash exists - if (!fullpath || fullpath.startsWith('old_hash') || fullpath.startsWith('access_token')) return null; + // IMS redirect fragments appear as '/ld_hash=', '/old_hash=', '/access_token=' in the path. + // fullpath always starts with '/' here, so strip it before the prefix check. + const pathContent = fullpath.slice(1); + if (!pathContent || pathContent.startsWith('old_hash') || pathContent.startsWith('access_token') || pathContent.startsWith('ld_hash')) return null; // Split everything up so it can be later used for both DA & AEM const pathParts = sanitizePathParts(fullpath);