Skip to content

fix: do not return empty query for empty array#8

Open
Tin wants to merge 1 commit intomike-spainhower:masterfrom
Tin:fix-empty-array-stringify
Open

fix: do not return empty query for empty array#8
Tin wants to merge 1 commit intomike-spainhower:masterfrom
Tin:fix-empty-array-stringify

Conversation

@Tin
Copy link

@Tin Tin commented May 10, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments