querystring
querystring copied to clipboard
fix: do not return empty query for empty array
# node v4.7.0
> require('querystring').stringify({filter: [], x: 1})
'x=1'
> require('querystring-es3').stringify({filter: [], x: 1})
'&x=1'
So the behavior is different with stock querystring module.
When using webpack 2, it seems that the querystring-es3
polyfilled the querystring
. Which may results &&
in query when some query is empty array. Which will be parsed as {'': ''}
in most web server implementation. And we are using Joi + Hapi.js as our server implementation. Which have 'allowUnkown => false' by default, the &&
will cause 400 error. So I think this fix should help avoid this kind of issue.