-
Notifications
You must be signed in to change notification settings - Fork 56
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
get_query_param' doesn't return duplicate parameters #61
Comments
From the mli: (** [get_query_param' q key] returns the list of values for the
[key] parameter in query [q]. Note that an empty list is not the
same as a [None] return value. For a query [foo], the mapping is:
- [/] returns None
- [/?foo] returns Some []
- [/?foo=] returns [Some [""]]
- [/?foo=bar] returns [Some ["bar"]]
- [/?foo=bar,chi] returns [Some ["bar","chi"]]
Query keys can be duplicated in the URI, in which case the first
one is returned. If you want to resolve duplicate keys, obtain
the full result set with {! query } instead.
*)
val get_query_param' : t -> string -> string list option I can understand the desire for a combination of all query parameters with the same name. The choice was taken in 1.x to preserve the literal structure of the URI being parsed in the interface. Perhaps we should add a function like: (** [get_query_params q key] returns all values found for a [key] in query [q]. *)
val get_query_params : t -> string -> string option list Issue #17 is related to this because We could also offer a way to ignore the distinction between a missing value and an empty value. What do you think? |
What is the literal structure here? You mean the order of the paremeters should be preserved? |
The order of parameters, presence/absence of There are two reasons for this:
I made a design mistake back around 1.3 or so when I introduced the "handy" comma-separated list query value form. This makes collecting duplicate values for the same key harder than it should be and is almost completely unnecessary. I did it because I wanted to avoid a |
I understand the situation. Practically, this is inconvenience because HTML IMHO, expecting a good equality property for URIs is hard. How about introducing a concept "canonical URIs" for equality check? |
This code is expected to return
Some ["1"; "2"]
.The text was updated successfully, but these errors were encountered: