feat(router-core): pass the param key to search parse/stringify callbacks#7568
feat(router-core): pass the param key to search parse/stringify callbacks#7568icholy wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughQuery string encoding and search parameter parsing/stringification now pass the parameter key to callbacks. ChangesKey-Aware Search Parameter Callbacks
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
packages/router-core/tests/searchParams.test.ts (1)
107-121: 💤 Low valueMinor inconsistency in parameter naming.
On Line 114, the
parsercallback instringifySearchWithuses a single-parameter signature(value) => JSON.parse(value), while thestringifycallback above uses the new two-parameter signature. This is functionally correct (TypeScript allows this), but for clarity and consistency with the new API, consider using(value, key) => JSON.parse(value)to make it explicit that the key is available but ignored.✨ Optional consistency improvement
const stringify = stringifySearchWith( (value, key) => (key === 'q' ? String(value) : JSON.stringify(value)), - (value) => JSON.parse(value), + (value, key) => JSON.parse(value), )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/router-core/tests/searchParams.test.ts` around lines 107 - 121, The two callbacks passed to stringifySearchWith should use the same two-parameter signature for consistency: change the second parser callback from a single-arg form to a two-arg form so it matches the first callback and the new API (i.e., update the second argument passed to stringifySearchWith to a function with parameters (value, key) that calls JSON.parse(value)); this keeps parseSearchWith and stringifySearchWith usage consistent and makes the unused key explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/router-core/tests/searchParams.test.ts`:
- Around line 107-121: The two callbacks passed to stringifySearchWith should
use the same two-parameter signature for consistency: change the second parser
callback from a single-arg form to a two-arg form so it matches the first
callback and the new API (i.e., update the second argument passed to
stringifySearchWith to a function with parameters (value, key) that calls
JSON.parse(value)); this keeps parseSearchWith and stringifySearchWith usage
consistent and makes the unused key explicit.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a0179c9a-4569-4a8a-abce-4f356865c85a
📒 Files selected for processing (5)
docs/router/guide/custom-search-param-serialization.mdpackages/router-core/src/qss.tspackages/router-core/src/searchParams.tspackages/router-core/tests/qss.test.tspackages/router-core/tests/searchParams.test.ts
Update
parseSearchWithandstringifySearchWithto pass the param'skeyas a second argument to the parsing callbacks. This allows individual params to be serialized differently.The problem
I have a numeric
orgparam in my code which I didn't want to be escaped, so?org=1rather than the default's JSON-quoted?org=%221%22. This was my first pass:With this change
I figured it would make more sense for this to be directly supported.
Summary by CodeRabbit
New Features
Documentation
Tests