-
Notifications
You must be signed in to change notification settings - Fork 271
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
Addressable wrong query_values when parsing query with array params #282
Comments
I think the Stack Overflow thread Is array syntax using square brackets in URL query strings valid? might help explain the lack of support in Addressable. The accepted answer starts out with
Had to check myself, and percent encoding doesn't work either: $ irb -raddressable/uri
irb(main):001:0> Addressable::VERSION::STRING
=> "2.5.2"
irb(main):002:0> uri = Addressable::URI.parse("http://foo.com/?abc%5B%5D=123&abc%5B%5D=456")
=> #<Addressable::URI:0x3fe170044e30 URI:http://foo.com/?abc%5B%5D=123&abc%5B%5D=456>
irb(main):003:0> uri.query_values
=> {"abc[]"=>"456"}
irb(main):004:0> uri.to_s
=> "http://foo.com/?abc%5B%5D=123&abc%5B%5D=456"
irb(main):005:0> Addressable::URI.parse(uri.to_s)
=> #<Addressable::URI:0x3fe170031790 URI:http://foo.com/?abc%5B%5D=123&abc%5B%5D=456>
irb(main):006:0> Addressable::URI.parse(uri.to_s).query_values
=> {"abc[]"=>"456"} |
Yes, percent doesn't work either and btw it will be enough for me, to make it work... |
I think that also when setting a given query param to array value, it should turn to uri = Addressable::URI.parse 'http://foo.com/'
uri.query_values = { abc: [123, 456] }
uri.to_s # => http://foo.com/?abc%5B%5D=123&abc%5B%5D=456 Instead of |
|
You can also find plenty of examples of query parameters that are repeated, both in the wild, and in some cases, in specifications. The model of using |
Please have a look on the following example
expected query value is
{"par": ["1", "2", "3"]}
Also this is very strange:
Which is really inconsistent...
The text was updated successfully, but these errors were encountered: