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

Utils.build_nested_query to handle empty arrays and hashes #698

Merged
merged 1 commit into from Aug 3, 2014
Merged

Utils.build_nested_query to handle empty arrays and hashes #698

merged 1 commit into from Aug 3, 2014

Conversation

IvanUkhov
Copy link
Contributor

Hello,

In master we have the following:

Rack::Utils.build_nested_query('foo' => 'bar', 'baz' => []) #=> "foo=bar&"
Rack::Utils.build_nested_query('foo' => 'bar', 'baz' => {}) #=> "foo=bar&"

The pull request turns it into:

Rack::Utils.build_nested_query('foo' => 'bar', 'baz' => []) #=> "foo=bar"
Rack::Utils.build_nested_query('foo' => 'bar', 'baz' => {}) #=> "foo=bar"

Regards,
Ivan

@IvanUkhov IvanUkhov changed the title Utils.build_nested_query to handle hashes whose values are empty arrays Utils.build_nested_query to handle empty arrays and hashes Jun 16, 2014
@mikegee
Copy link
Contributor

mikegee commented Jun 18, 2014

Does this fix something that is broken or does it just make the url look a little better?

@IvanUkhov
Copy link
Contributor Author

@mikegee, although there are rather mild restrictions on the format of a query string in general, it is very specific in certain contexts. For example, according to the W3C, a query string of a form is a set of pairs separated by the ampersand, and each pair is composed of a key and a value separated by the equals sign. Therefore, if we split foo=bar& by the ampersand, the second pair will be invalid.

I believe that most of the parser nowadays will not have any problems with foo=bar&; I just consider it to be a kind of pollution, and I want the Internet to be clean.

Regards,
Ivan

@raggi raggi added this to the Rack 1.6 milestone Jul 5, 2014
raggi added a commit that referenced this pull request Aug 3, 2014
Utils.build_nested_query to handle empty arrays and hashes
@raggi raggi merged commit 6ee42d6 into rack:master Aug 3, 2014
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.

None yet

3 participants