Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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