-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
refactor(router-core): throw redirect w/ a pre-build location doesn't need to re-parse from string #6512
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
refactor(router-core): throw redirect w/ a pre-build location doesn't need to re-parse from string #6512
Conversation
… need to re-parse from string
📝 WalkthroughWalkthroughThe PR introduces an internal Changes
Sequence DiagramsequenceDiagram
participant Router
participant RedirectHandler as Redirect Handler
participant LocationBuilder as Location Builder
Router->>RedirectHandler: resolveRedirect(redirect, location)
alt _builtLocation provided
RedirectHandler->>LocationBuilder: Use _builtLocation directly
LocationBuilder->>LocationBuilder: Skip protocol & URL parsing
else No _builtLocation
RedirectHandler->>LocationBuilder: Build new location from options
LocationBuilder->>LocationBuilder: Execute full parsing logic
end
LocationBuilder->>Router: Return location for redirect
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
|
View your CI Pipeline Execution ↗ for commit deb48d8
☁️ Nx Cloud last updated this comment at |
During SSR, if the href of an incoming request ends up matching and being re-written to another href (for example: adding default search params), we throw a
redirect({ href })with that new href to force aResponse(, { headers: { Location: href } })When handling a thrown
redirect, we treathrefas any untrusted string. This is sub-optimal when it actually comes from us just parsing a correct internal location.This PR proposes an internal
_builtLocationargument that bypasses such checks and re-parsing.before

after
