From 333bcf9ae1386bd1c4f720d722e34d277a3e5e34 Mon Sep 17 00:00:00 2001 From: Ismail Memon Date: Thu, 23 Apr 2026 20:22:59 +0500 Subject: [PATCH 1/2] fix: handle existing query params in preview iframe URL --- code/core/src/manager-api/modules/url.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/core/src/manager-api/modules/url.ts b/code/core/src/manager-api/modules/url.ts index 67b94017b0bf..d827cc1e2742 100644 --- a/code/core/src/manager-api/modules/url.ts +++ b/code/core/src/manager-api/modules/url.ts @@ -282,10 +282,10 @@ export const init: ModuleFn = (moduleArgs) => { globalsParam = globalsParam && `&globals=${globalsParam}`; customManagerParams = customManagerParams && `&${customManagerParams}`; customPreviewParams = customPreviewParams && `&${customPreviewParams}`; - + const separator = previewBase.includes('?') ? '&' : '?'; return { managerHref: `${managerBase}?path=/${viewMode}/${refId ? `${refId}_` : ''}${storyId}${argsParam}${globalsParam}${customManagerParams}`, - previewHref: `${previewBase}?id=${storyId}&viewMode=${viewMode}${refParam}${argsParam}${refId ? '' : globalsParam}${customPreviewParams}`, + previewHref: `${previewBase}${separator}id=${storyId}&viewMode=${viewMode}${refParam}${argsParam}${refId ? '' : globalsParam}${customPreviewParams}`, }; }, getQueryParam(key) { From f89fe6cc584c65b9cde65ded85240a8d8923f236 Mon Sep 17 00:00:00 2001 From: Ismail Memon Date: Fri, 24 Apr 2026 00:51:50 +0500 Subject: [PATCH 2/2] fix: handle query strings and hash fragments in preview iframe URL --- code/core/src/manager-api/modules/url.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/core/src/manager-api/modules/url.ts b/code/core/src/manager-api/modules/url.ts index d827cc1e2742..e6a76a0dad11 100644 --- a/code/core/src/manager-api/modules/url.ts +++ b/code/core/src/manager-api/modules/url.ts @@ -282,10 +282,15 @@ export const init: ModuleFn = (moduleArgs) => { globalsParam = globalsParam && `&globals=${globalsParam}`; customManagerParams = customManagerParams && `&${customManagerParams}`; customPreviewParams = customPreviewParams && `&${customPreviewParams}`; - const separator = previewBase.includes('?') ? '&' : '?'; + const hashIndex = previewBase.indexOf('#'); + const previewBaseWithoutHash = + hashIndex === -1 ? previewBase : previewBase.slice(0, hashIndex); + const previewHash = hashIndex === -1 ? '' : previewBase.slice(hashIndex); + const separator = previewBaseWithoutHash.includes('?') ? '&' : '?'; + return { managerHref: `${managerBase}?path=/${viewMode}/${refId ? `${refId}_` : ''}${storyId}${argsParam}${globalsParam}${customManagerParams}`, - previewHref: `${previewBase}${separator}id=${storyId}&viewMode=${viewMode}${refParam}${argsParam}${refId ? '' : globalsParam}${customPreviewParams}`, + previewHref: `${previewBaseWithoutHash}${separator}id=${storyId}&viewMode=${viewMode}${refParam}${argsParam}${refId ? '' : globalsParam}${customPreviewParams}${previewHash}`, }; }, getQueryParam(key) {