-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix(router-core): normalize pipe characters in paths to prevent redirect loops #6293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request adds support for the pipe character ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
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 |
|
@jong-kyung thanks for this. as part of my review process, I like to recreate the error with the e2e tests before validating the fix. I copied the e2e test over into main and the tests passed without a problem. I also tested this manually in the browser and could not replicate the problem. We need to ensure the e2e test fails with the expected error and the solution resolves it correctly to ensure future breakages are avoided. I do see the error in the linked issue but unfortunately, I don't see the source. Would it be possible to link to a github repo or stackblitz link where the error re-occurs? |
|
I see now you aren't the author of the original issue. Do you possibly have a recreation of the original problem? |
|
Hi @nlynzaad, thanks for reviewing Apologies for the confusion regarding the E2E test. The test passed because I added it to a CSR-only. This issue (ERR_TOO_MANY_REDIRECTS) is specific to SSR environments (TanStack Start), caused by a mismatch between browser encoding and server-side normalization during direct navigation. You can reproduce the issue using the links below:
Could you please confirm the issue using the reproduction links? Once confirmed, please let me know, and I will rewrite the tests to properly target the SSR environment based on your feedback. Thanks again for your time and review, and sorry for the confusion |
fixes #6288
This PR fixes an issue where using a pipe character (
|) in route parameters caused an infinite redirect loop (ERR_TOO_MANY_REDIRECTS)The Problem
Browsers automatically encode
|characters to%7Cin the URL when navigating directly. However, the router's internal normalization logic (cleanPath) was treating|as a raw character.This caused a mismatch between the current location (encoded by browser) and the expected location (unencoded by router), triggering a redirect loop where the router tried to redirect to the unencoded path, but the browser re-encoded it upon request.
The Fix
I updated the
cleanPathutility function to explicitly normalize|characters to%7C. This ensures that the router's internal path representation matches the browser's encoding behavior, preventing the unnecessary redirect loop.Changes
cleanPathto replace|with%7C.Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.