fix: sanitizeUrl incorrectly rewrites internal navigation links#39706
fix: sanitizeUrl incorrectly rewrites internal navigation links#39706vmridul wants to merge 3 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 0da95e2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
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 (3)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
**/*.spec.ts📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (14)📓 Common learnings📚 Learning: 2026-03-16T21:50:37.589ZApplied to files:
📚 Learning: 2025-11-24T17:08:17.065ZApplied to files:
📚 Learning: 2025-11-24T17:08:17.065ZApplied to files:
📚 Learning: 2025-11-24T17:08:17.065ZApplied to files:
📚 Learning: 2025-11-24T17:08:17.065ZApplied to files:
📚 Learning: 2025-11-24T17:08:17.065ZApplied to files:
📚 Learning: 2025-11-24T17:08:17.065ZApplied to files:
📚 Learning: 2025-12-10T21:00:43.645ZApplied to files:
📚 Learning: 2026-02-24T19:22:48.358ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-03-06T18:02:11.732ZApplied to files:
📚 Learning: 2026-03-06T18:10:15.268ZApplied to files:
🔇 Additional comments (5)
WalkthroughA patch release for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
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 Tip CodeRabbit can approve the review once all CodeRabbit's comments are resolved.Enable the |
Problem
sanitizeUrl()was forcing all protocol less URLs into protocol relative form (//...), which broke internal links like/channel/general,./docs,#section,?tab=files. This caused rendered markdown links in messages to navigate incorrectly or fail.Before
When a user posted a markdown link to an internal page or anchor:
/channel/generalwas rewritten as///channel/general(browser treats this as a network request instead of a route)#sectionwas rewritten as//#section?tab=fileswas rewritten as//?tab=filesResult: clicking internal links in chat messages would either navigate to wrong page or stay on current page.
After
Internal link patterns are now recognized and passed through unchanged:
/channel/generalstays/channel/general#sectionstays#section?tab=filesstays?tab=filesAll other link types continue to work normally (external domains, XSS blocking, etc.)
Solution
Added a check to preserve URLs starting with
/,./,../,#, or?before the existing domain-rewriting logic.Changes
packages/gazzodown/src/elements/sanitizeUrl.ts: Added check to preserve internal/local URLspackages/gazzodown/src/elements/sanitizeUrl.spec.ts: Added 3 test cases covering relative paths, hash fragments, and query only linksSummary by CodeRabbit
Bug Fixes
Tests