{"action":"created","issue":{"url":"https://api.github.com/repos/postmodern/uri-query_params/issues/4","labels_url":"https://api.github.com/repos/postmodern/uri-query_params/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/postmodern/uri-query_params/issues/4/comments","events_url":"https://api.github.com/repos/postmodern/uri-query_params/issues/4/events","html_url":"https://github.com/postmodern/uri-query_params/issues/4","id":115703031,"number":4,"title":"Arrays and other thoughts ","user":{"login":"mvastola","id":599767,"avatar_url":"https://avatars.githubusercontent.com/u/599767?v=3","gravatar_id":"","url":"https://api.github.com/users/mvastola","html_url":"https://github.com/mvastola","followers_url":"https://api.github.com/users/mvastola/followers","following_url":"https://api.github.com/users/mvastola/following{/other_user}","gists_url":"https://api.github.com/users/mvastola/gists{/gist_id}","starred_url":"https://api.github.com/users/mvastola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvastola/subscriptions","organizations_url":"https://api.github.com/users/mvastola/orgs","repos_url":"https://api.github.com/users/mvastola/repos","events_url":"https://api.github.com/users/mvastola/events{/privacy}","received_events_url":"https://api.github.com/users/mvastola/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-11-08T01:05:21Z","updated_at":"2015-12-02T02:52:33Z","closed_at":null,"body":"First off, this is an AWESOME gem, because it uniquely provides functionality the built-in `URI` library is *sorely* lacking. Thank you for coding it.\r\n\r\nThe difficulty with this library I think is actually the fact that things are a lot more complicated than they seem at first glance. As a result, some thoughts on features this gem should seek to incorporate/aspire to..\r\n* in some use cases (especially surrounding adding cryptographic signatures to API requests) the exact order of the parameters matters. Often it's alphabetical, but rules can vary. The best solution here is probably to ensure the exposed object returned by `#query_params` is an `OrderedHash` rather than an ordinary one (if not an entirely custom object).\r\n* Rails in particular has a tendency to use arrays in form element names. So if I have an array of text fields and submit them, I run into this problem:\r\n```\r\n2.1.2 :009 > u = URI.parse(\"http://google.com/?list[items][]=1&list[items][]=2\")\r\n => #<URI::HTTP:0x0000000aa61698 URL:http://google.com/?list[items][]=1&list[items][]=2> \r\n2.1.2 :010 > u.query\r\n => \"list[items][]=1&list[items][]=2\" \r\n2.1.2 :011 > u.query_params\r\n => {\"list[items][]\"=>\"2\"}\r\n```\r\n  * Obviously the first issue here is that `u.query_params` should be returning a `Hash` with one key whose value is an array with the elements `1` and `2`, because that's what `params[:list][:items]` will return to a Rails controller.\r\n  * A second issue is one with your implementation that's a bit more insidious. By the simple act of *calling* `#query_params` it seems, without ever setting any values within the object. I have manipulated my `URI` object. These lines in the IRB console immediately follow those above:\r\n```\r\n2.1.2 :012 > u.query\r\n => \"list[items][]=2\" \r\n2.1.2 :013 > u\r\n => #<URI::HTTP:0x0000000aa61698 URL:http://google.com/?list[items][]=2>\r\n```\r\nThis makes this gem completely unusable for me right now because so much as `require`ing it risks corrupting URLs that are parsed by the `URI` class in certain cases.\r\n\r\nI'm very interested to see where you go with this though and might even be interested to work with you on fixing these bugs. Please let me know what you think in regards to my comments and if you develop some sort of plan for resolving the issues I have brought up.\r\n\r\nThanks,\r\nMike"},"comment":{"url":"https://api.github.com/repos/postmodern/uri-query_params/issues/comments/161162496","html_url":"https://github.com/postmodern/uri-query_params/issues/4#issuecomment-161162496","issue_url":"https://api.github.com/repos/postmodern/uri-query_params/issues/4","id":161162496,"user":{"login":"mvastola","id":599767,"avatar_url":"https://avatars.githubusercontent.com/u/599767?v=3","gravatar_id":"","url":"https://api.github.com/users/mvastola","html_url":"https://github.com/mvastola","followers_url":"https://api.github.com/users/mvastola/followers","following_url":"https://api.github.com/users/mvastola/following{/other_user}","gists_url":"https://api.github.com/users/mvastola/gists{/gist_id}","starred_url":"https://api.github.com/users/mvastola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvastola/subscriptions","organizations_url":"https://api.github.com/users/mvastola/orgs","repos_url":"https://api.github.com/users/mvastola/repos","events_url":"https://api.github.com/users/mvastola/events{/privacy}","received_events_url":"https://api.github.com/users/mvastola/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T02:52:32Z","updated_at":"2015-12-02T02:52:32Z","body":"Unfortunately, I don't think so. A lot of APIs do authentication of requests by performing a cryptographic hash on a the request URI that involves the key. This hash is then appended to the querystring as a new param or sent as an X header.\r\n\r\nThe other side (which also must know the secret key) then works backword, isolating the request URI and following the same calculaton steps before checking for a match.\r\n\r\nSee Twilio's authentation for an example. (Though they don't use multiple params that I know of.)"}}