refactor(router-core): parseLocation fast path w/ no rewrites#6516
refactor(router-core): parseLocation fast path w/ no rewrites#6516
Conversation
|
View your CI Pipeline Execution ↗ for commit b542bc1
☁️ Nx Cloud last updated this comment at |
📝 WalkthroughWalkthroughAdded a fast path to parseLocation in router-core that skips URL construction and rewrite processing when no rewrite is configured and the pathname contains no characters requiring encoding; adjusted hash extraction and preserved external-origin detection logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/router-core/src/router.ts`:
- Around line 1254-1281: The Biome lint failure is due to the control-character
regex inside the parse function; update the regex usage in ParsedLocation
creation so it no longer triggers the lint: either replace the literal /[
\x00-\x1f\x7f\u0080-\uffff]/ with a RegExp constructed string (new RegExp('[
\\x00-\\x1f\\x7f\\u0080-\\uffff]')) or add a Biome ignore comment immediately
above the regex to suppress the rule; ensure the change targets the regex in the
parse method of router.ts and preserves the same semantics for the fast-path
check (!this.rewrite && !/.../.test(pathname)).
When no rewrites are configured, we can entirely skip creating a
URLobject and reuse directly the providedpathname,searchandhashbefore

after

Summary by CodeRabbit
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.