Closed seliopou closed 9 years ago
This is not part of the spec as query string syntax is not standardized.
I don't believe this is a bug because:
# Uri.(query (of_string ""));;
- : (string * string list) list = []
# Uri.(query (of_string "?"));;
- : (string * string list) list = [("", [])]
# Uri.(query (of_string "?="));;
- : (string * string list) list = [("", [""])]
# Uri.(query (of_string "?=,"));;
- : (string * string list) list = [("", [""; ""])]
# Uri.(query (of_string "?=,&"));;
- : (string * string list) list = [("", [""; ""]); ("", [])]
That is, if you have an empty query, the query you have is the query with an empty key and no values. If you don't have a query, this is a different case. I recommend using the query
accessor and with_query
and with_query'
functions when dealing with queries. These functions are aware of the whole URI and so Do The Right Thing with the query constructor ?
.
# Uri.(to_string (with_query (of_string "") []));;
- : string = ""
# Uri.(to_string (with_query (of_string "") ["",[]]));;
- : string = "?"
I hope this answers your question. Please feel free to close this issue if you are satisfied.
Thanks for your report!
This behavior makes a bit more sense to me now. I lightly disagree with it still, but I can understand why it's like that. Thanks!
Closing.
Uri.query_of_encoded ""
returns a non-empty list:It surprised me that it has this behavior. Is it somehow part of the spec, or is it a bug?