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

Setting a duplicate search parameter using Interceptor.query should throw an error #1623

Closed
mastermatt opened this issue Jul 15, 2019 · 2 comments

Comments

@mastermatt
Copy link
Member

Context
#1614 (comment)

In order to gain full code coverage, a test was added to show current expected behavior around what happens if a search param is set twice.

nock('http://example.test')
    .get('/')
    .query({ foo: 'bar' })
    .query({ foo: 'baz' })
    .reply()

Current behavior prefers the first value and silently ignores any subsequent values. This example will match http://example.test?foo=bar.

This is confusing and probably hides unintended bugs by users.

Alternatives

Interceptor.query should throw an error if a duplicate key is provided with a clear error message.
The "key" being checked should be the value returned by formatQueryValue instead of the input key.

The new test from #1614 should be updated test the new expected behavior.

mastermatt added a commit to mastermatt/nock that referenced this issue Jul 15, 2019
Resolves nock#1623

BREAKING CHANGE: Providing a duplicate search parameter to the `query`
method throws an error instead of ignoring subsequent values.
gr2m pushed a commit that referenced this issue Jul 15, 2019
Resolves #1623

BREAKING CHANGE: Providing a duplicate search parameter to the `query`
method throws an error instead of ignoring subsequent values.
@nockbot
Copy link
Collaborator

nockbot commented Jul 15, 2019

🎉 This issue has been resolved in version 11.0.0-beta.26 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nockbot
Copy link
Collaborator

nockbot commented Aug 13, 2019

🎉 This issue has been resolved in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

gr2m pushed a commit that referenced this issue Sep 4, 2019
Resolves #1623

BREAKING CHANGE: Providing a duplicate search parameter to the `query`
method throws an error instead of ignoring subsequent values.
gr2m pushed a commit that referenced this issue Sep 4, 2019
Resolves #1623

BREAKING CHANGE: Providing a duplicate search parameter to the `query`
method throws an error instead of ignoring subsequent values.
gr2m pushed a commit that referenced this issue Sep 5, 2019
Resolves #1623

BREAKING CHANGE: Providing a duplicate search parameter to the `query`
method throws an error instead of ignoring subsequent values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants