querystring icon indicating copy to clipboard operation
querystring copied to clipboard

fix: do not return empty query for empty array

Open Tin opened this issue 7 years ago • 0 comments

# 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.

Tin avatar May 10 '17 01:05 Tin