Skip to content
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

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

s-taylor
Copy link
Contributor

@s-taylor s-taylor commented May 26, 2017

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 using qs elsewhere.

The result then becomes...
.query({"foo":["bar","baz"]})
Which now matches the superagent query input.

Resolves #896

@coveralls
Copy link

coveralls commented May 26, 2017

Coverage Status

Coverage decreased (-0.005%) to 92.681% when pulling aa6053c on s-taylor:master into 17d7c25 on node-nock:master.

@s-taylor
Copy link
Contributor Author

s-taylor commented May 26, 2017

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.

@s-taylor
Copy link
Contributor Author

Any updates on this? I've had to use my forked version as recording doesn't match for us without this.

@travi
Copy link
Contributor

travi commented Aug 23, 2017

i'd really appreciate getting this merged as well since this is the behavior that is expected for my project as well

@paulmelnikow
Copy link
Member

The bug being fixed is that duplicate keys in the query string e.g. ?a=1&a=2&a=3 are lost. Is that correct?

@s-taylor
Copy link
Contributor Author

Correct, it only records one value. The fix records this as an array.

@paulmelnikow
Copy link
Member

paulmelnikow commented Sep 22, 2017

Makes sense. Though the fix makes sense to me, the test seems very indirect. Could it be written in a simpler way?

@eddiemoore
Copy link

Would love to see this in nock as well.

@gr2m
Copy link
Member

gr2m commented Sep 28, 2017

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

@coveralls
Copy link

coveralls commented Sep 28, 2017

Coverage Status

Coverage decreased (-0.005%) to 92.666% when pulling dfa7dde on s-taylor:master into b050c49 on node-nock:master.

@gr2m gr2m merged commit 574d69b into nock:master Sep 28, 2017
@gr2m
Copy link
Member

gr2m commented Sep 28, 2017

sorry for the delay folks, I’ll release it as a new version right away

@gr2m
Copy link
Member

gr2m commented Sep 28, 2017

released in nock@9.0.22

@travi
Copy link
Contributor

travi commented Sep 28, 2017

Thanks @gr2m!

@s-taylor
Copy link
Contributor Author

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!

@travi
Copy link
Contributor

travi commented Oct 3, 2017

i confirmed that this solves the problem that we had. thanks again @gr2m and @s-taylor

@lock
Copy link

lock bot commented Sep 13, 2018

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!

@lock lock bot locked as resolved and limited conversation to collaborators Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants