It appears nock mixes usage of native node querystring module and npm installed qs module for parsing querystring-like objects.
In nock/lib/interceptor.js it requires qs (a dependency in package.json), but in nock/lib/match_body.js it requires querystring, the native node library.
These two libraries have different outputs. For example:
var query = require('querystring');
var qs = require('qs');
query.parse('a%5Bb%5D=test'); // => { 'a[b]': 'test' }
qs.parse('a%5Bb%5D=test'); // => { a: { b: 'test' } }
This means interceptors and body matchers have different behavior.
@jeffora Good catch.
A PR would be welcome..
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions.
Which dependency would be desirable to keep? 'querystring' or 'qs' ?
Which dependency would be desirable to keep? 'querystring' or 'qs' ?
I think native 'querystring'
see https://github.com/nock/nock/pull/563#issuecomment-338104773
I think this is a good idea, though it will be a breaking change to body matching. For example, It will break use cases like this one:
I suggest we add a flag to allow users who use array syntax and qs-style encoding to keep using it. We could make qs an optionalDependency.
:tada: This issue has been resolved in version 11.0.0-beta.30 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This issue has been resolved in version 11.0.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Most helpful comment
I think native 'querystring'
see https://github.com/nock/nock/pull/563#issuecomment-338104773