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

Empty arrays/objects add unnecessary & symbols #4

Closed
chrisvanpatten opened this issue Jun 17, 2018 · 0 comments
Closed

Empty arrays/objects add unnecessary & symbols #4

chrisvanpatten opened this issue Jun 17, 2018 · 0 comments

Comments

@chrisvanpatten
Copy link

chrisvanpatten commented Jun 17, 2018

In PHP, keys with empty arrays or objects are not added to the query string.

For example in PHP:

http_build_query([ 'dog' => 1, 'cat' => [], 'mouse' => new StdClass(), 'rabbit' => 2 ]);
// Returns: "dog=1&rabbit=2"

Interactive PHP test case: https://3v4l.org/l1haG

http-build-query doesn't add these to the query string, which is correct, but does add extraneous & symbols:

hbq( { 'dog': 1, 'cat': [], 'mouse': {}, 'rabbit': 2 } );
// Returns: "dog=1&&&rabbit=2"

Interactive JS test case: https://runkit.com/cvp/5b265e43c28df80012c7edd7

These extra & symbols don't hurt anything, but don't match the PHP implementation.

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

No branches or pull requests

1 participant