{"action":"opened","issue":{"url":"https://api.github.com/repos/vladzadvorny/http-build-query/issues/4","repository_url":"https://api.github.com/repos/vladzadvorny/http-build-query","labels_url":"https://api.github.com/repos/vladzadvorny/http-build-query/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/vladzadvorny/http-build-query/issues/4/comments","events_url":"https://api.github.com/repos/vladzadvorny/http-build-query/issues/4/events","html_url":"https://github.com/vladzadvorny/http-build-query/issues/4","id":333061863,"node_id":"MDU6SXNzdWUzMzMwNjE4NjM=","number":4,"title":"Empty arrays/objects add unnecessary `&` symbols","user":{"login":"chrisvanpatten","id":1231306,"node_id":"MDQ6VXNlcjEyMzEzMDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1231306?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisvanpatten","html_url":"https://github.com/chrisvanpatten","followers_url":"https://api.github.com/users/chrisvanpatten/followers","following_url":"https://api.github.com/users/chrisvanpatten/following{/other_user}","gists_url":"https://api.github.com/users/chrisvanpatten/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisvanpatten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisvanpatten/subscriptions","organizations_url":"https://api.github.com/users/chrisvanpatten/orgs","repos_url":"https://api.github.com/users/chrisvanpatten/repos","events_url":"https://api.github.com/users/chrisvanpatten/events{/privacy}","received_events_url":"https://api.github.com/users/chrisvanpatten/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-17T13:13:16Z","updated_at":"2018-06-17T13:13:16Z","closed_at":null,"author_association":"NONE","body":"In PHP, keys with empty arrays or objects are not added to the query string.\r\n\r\nFor example in PHP:\r\n\r\n```php\r\nhttp_build_query([ 'dog' => 1, 'cat' => [], 'mouse' => new StdClass(), 'rabbit' => 2 ]);\r\n// Returns: \"dog=1&rabbit=2\"\r\n```\r\n\r\n`http-build-query` doesn't add these to the query string, which is correct, but does add extraneous `&` symbols:\r\n\r\n```js\r\nhbq( { 'dog': 1, 'cat': [], 'mouse': {}, 'rabbit': 2 } );\r\n// Returns: \"dog=1&&&rabbit=2\"\r\n```\r\n\r\nInteractive test case: https://runkit.com/cvp/5b265e43c28df80012c7edd7\r\n\r\nThese extra `&` symbols don't hurt anything, but don't match the PHP implementation."}}
{"actor":{"display_login":"chrisvanpatten"}}