Skip to content

Queryparams incorrectly parsing arrays #30

@racinmat

Description

@racinmat

Representing an array in query parameter is tricky and there is no single true way, but I think at least one of the often-used approaches should be supported.
Current behavior is:

julia> using URIs
julia> queryparams("foo=bar,qux")
Dict{String,String} with 1 entry:
  "foo" => "bar,qux"

julia> queryparams("foo[]=bar&foo[]=qux")
Dict{String,String} with 1 entry:
  "foo[]" => "qux"

julia> queryparams("foo=bar&foo=qux")
Dict{String,String} with 1 entry:
  "foo" => "qux"

julia> queryparams("foo%5B%5D=bar&foo%5B%5D=qux")
Dict{String,String} with 1 entry:
  "foo[]" => "qux"

I would expect all of them, or at least the ones with repeated foo to return an array instead of string with single value.
It would make the type-stability more complicated, because now it's Dict{String,String}, so accommodating arrays there would mean changing it probably to Dict{String,Union{Vector},String}}?
I'm not sure how the proper solution should look like, but we should not definitely lose parameters as the current behavior does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions