[erlang-questions] url query string encode/decode

Roger Lipscombe roger@REDACTED
Fri Dec 15 14:38:22 CET 2017


On 15 December 2017 at 13:22, Loïc Hoguin <essen@REDACTED> wrote:
> The keys are not unique actually. Browsers will actually send query strings
> with duplicate keys if there are duplicate names in forms. That's actually
> how PHP's name[]=value thing works, you get many name[] keys in the query
> string.

Yeah; I know they don't have to be unique. My point was that there's
no *standard* for how non-unique keys should be handled, so it's no
real surprise when different implementations do different things with
them.

> Cowboy will happily return duplicate keys whether you use
> cowboy_req:parse_qs (which calls the equivalent function in cowlib) or
> cowboy_req:match_qs, in the latter case you get a map like #{name =>
> [<<"a">>, <<"b">>, <<"c">>]}. It doesn't require the [] or any other
> indicator for this. (But if you want to name your key 'name[]', no problem
> either.)

This is good to know. Thanks.



More information about the erlang-questions mailing list