-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix: merge URLSearchParams qs arguments #134
Conversation
* use modern classes * use assert instead of assertive
and add test for qs merging
```js const client = new Gofer({ c: { qs: { id: 'x' } } }, 'c'); // both of these now work and request /go?id=x&other=y await client.get('/go', { qs: { other: 'y' } }); // fixed await client.get('/go', { qs: new URLSearchParams({ other: 'y' }) }); ```
function preventComplexMerge(objValue, srcValue) { | ||
function goferMerge(objValue, srcValue) { |
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.
Just renamed to reflect broader functionality
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.
sweet 💚
values for a given key replace all values for existing key (don't think this rises to the level of breaking): ```js const config = { c: { qs: { a: '1', b: '3' } } }; const client = new Gofer(config, 'c'); console.log(client.getMergedOptions( {}, { qs: new URLSearchParams([['a', '2'], ['a', '4']]) } )); // before: // new URLSearchParams([['a', '1'], ['b', '3'], ['a', '2'], ['a', '4']]) // now: (note existing a: 1 has been removed) // new URLSearchParams([['a', '2'], ['b', '3'], ['a', '4']]) ```
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.
💚
NOTE: values for a given key replace all values for existing key
(don't think this rises to the level of breaking):
This PR was started by: git wf pr