Incorrect parsing of query strings
it is perfectly valid to have ?a=1&a=2 unfortunately as it uses a dictionary internally, these get squashed. i'll try and patch next week.
So what value should be under a key? In PHP $_GET['a'] will return 2 (Miuri also returns 2).
I believe it's valid behavior.
PHP is broken then, but we all knew that.
On Friday, 22 February 2013, Radosław Mejer wrote:
So what value should be under a key? In PHP $_GET['a'] will return 2(Miuri also returns 2). I believe it's valid behavior.
— Reply to this email directly or view it on GitHubhttps://github.com/radmen/miuri.js/issues/4#issuecomment-13962558.
Ok, so what is the correct value then? Can You give something like RFC to show the right way?
The correct value would be for miuri to not delete duplicate params when parsing. i.e new Miuri("http://a.com?a=2&a=3') should not become http://a.com?a=2 when toString is called.
I'm not sure how you would make a backward compatible change to the query function in order to make it possible to set multiples though. jQuery uses a name, value dictionary.
I'm not sure how you would make a backward compatible change to the query function in order to make it possible to set multiples though.
Are You talking about arrays passed in GET (something like a[]=2&a[]=3)?
Yes, but that's just a hacky workaround PHP does. its perfectly valid to do a=1&a=2 sans square brackets
I searched a little at Google. You're right about passing arrays without brackets (didn't know that..). Yet it's not a common thing. jQuery e.g uses brackets (I've used $.param to check it).
Parsing query string to find arrays without brackets won't be much a problem. Building URI with arrays in query is a little bit tricky, because programmer will have to choose which option (brackets or no brackets) to use.