-
Notifications
You must be signed in to change notification settings - Fork 151
feat: allow passing URLSearchParams to query config
#490
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?
feat: allow passing URLSearchParams to query config
#490
Conversation
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #490 +/- ##
===========================================
+ Coverage 56.86% 86.51% +29.64%
===========================================
Files 16 5 -11
Lines 728 267 -461
Branches 113 134 +21
===========================================
- Hits 414 231 -183
+ Misses 303 32 -271
+ Partials 11 4 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
URLSearchParams to query config
| query: Record<string, any> | URLSearchParams | undefined | ||
| ) { | ||
| if (query instanceof URLSearchParams) { | ||
| return Object.fromEntries(query.entries()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use a safer one liner:
typeof query?.entries === 'function' ? Object.fromEntries(query.entries()) : queryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another issue here is that, we are loose multi-value:
const q = new URLSearchParams() // q.toString() === "tag=a&tag=b"
q.append("tag", "a")
q.append("tag", "b")
Object.fromEntries(q.entries()) // {tag: 'b'}
resolves #322