-
-
Notifications
You must be signed in to change notification settings - Fork 735
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 recording query strings, where value is an array #917
Conversation
BTW I think the coverage error doesn't make sense, it's probably because I deleted lines. Which has reduced the overall number of lines and therefore makes it look as though the coverage has dropped. My change is tested and all of the added lines will be covered by the test. |
Any updates on this? I've had to use my forked version as recording doesn't match for us without this. |
i'd really appreciate getting this merged as well since this is the behavior that is expected for my project as well |
The bug being fixed is that duplicate keys in the query string e.g. |
Correct, it only records one value. The fix records this as an array. |
Makes sense. Though the fix makes sense to me, the test seems very indirect. Could it be written in a simpler way? |
Would love to see this in nock as well. |
I’ve rebased the PR on the latest master. I agree with @paulmelnikow that the test seems indirect, but it very much follows the conventions of the other tests around it. About time to clean them up for good, but that’s out of scope. Let’s wait to see if CI is happy and if it is, let’s merge it in |
sorry for the delay folks, I’ll release it as a new version right away |
released in |
Thanks @gr2m! |
Thanks @gr2m , I would have been happy to add more tests but been busy and wasn't sure what additional tests you were after. Thanks for getting this merged! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you! |
This PR fixes an issue when using arrays inside a query string.
Prior to this change when using the following query string via superagent we get...
.query({"foo":["bar","baz"]})
The result is...
.query({"foo":"baz"})
Essentially the last value overrides any prior values due to the way the query string object is being formed. The fix is to simply use the
qs
library's.parse
function which makes sense since the library is usingqs
elsewhere.The result then becomes...
.query({"foo":["bar","baz"]})
Which now matches the superagent query input.
Resolves #896