fix: handle existing query params in preview iframe URL#34617
fix: handle existing query params in preview iframe URL#34617justismailmemon wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdated Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code/core/src/manager-api/modules/url.ts`:
- Around line 285-288: The preview URL construction puts added query params
after any existing hash fragment (so id/viewMode land in the fragment); update
previewHref generation to split previewBase on '#' (e.g., const
[baseWithoutHash, hashPart] = previewBase.split('#', 2)), compute the separator
against baseWithoutHash (const separator = baseWithoutHash.includes('?') ? '&' :
'?'), append the id/viewMode/other params to baseWithoutHash, then reassemble
previewHref as `${baseWithoutHash}${separator}...${hashPart ? `#${hashPart}` :
''}` so all new params are in the query string before any fragment; apply the
same approach if managerBase may include a fragment when building managerHref.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 75b1e0e2-a161-4a7d-8f6e-e70cd3422e96
📒 Files selected for processing (1)
code/core/src/manager-api/modules/url.ts
What I changed
This fixes malformed preview iframe URLs when
--preview-urlalready contains query parameters.Previously,
previewHrefalways appended Storybook params with a hardcoded?, which produced invalid URLs like:iframe.html?foo=bar?id=<story-id>&viewMode=storyThis change uses the correct separator based on whether
previewBasealready includes a query string:?when no query params exist yet&when query params are already presentExample
Before:
iframe.html?foo=bar?id=button--primary&viewMode=storyAfter:
iframe.html?foo=bar&id=button--primary&viewMode=storyWhy
--preview-urlcan be set to a URL that already includes query params. In that case, additional params must be appended with&instead of?.Closes #34615
Summary by CodeRabbit