What is the expected behavior?
Nock should not consider comma-separated query params to match array-based query params
What is the actual behavior?
If nock expects a comma-separated string as a query parameter, and an array-based parameter is set in the tested code, the two params are seen to be equal.
Possible solution
The problem, I believe, happens in matchStringOrRegexp. The interceptor sees the expected value is the comma-separated string (a string), it passes that and the qs.parsed query param (an array) to matchStringOrRegexp. matchStringOrRegexp will typecast the array to a string, meaning they will match:
matchStringOrRegexp([ 'abc', '123' ], 'abc,123') => true
How to reproduce the issue
https://runkit.com/jonogilmour/node-nock-query-issue
Does the bug have a test case?
Versions
| Software |
Version(s) |
| Nock |
10.0.0 |
| Node |
8.12.0 |
What is the expected behavior?
Nock should not consider comma-separated query params to match array-based query params
What is the actual behavior?
If nock expects a comma-separated string as a query parameter, and an array-based parameter is set in the tested code, the two params are seen to be equal.
Possible solution
The problem, I believe, happens in matchStringOrRegexp. The interceptor sees the expected value is the comma-separated string (a string), it passes that and the
qs.parsed query param (an array) to matchStringOrRegexp.matchStringOrRegexpwill typecast the array to a string, meaning they will match:matchStringOrRegexp([ 'abc', '123' ], 'abc,123') => trueHow to reproduce the issue
https://runkit.com/jonogilmour/node-nock-query-issue
Does the bug have a test case?
Versions