-
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
Uri.path broken ? #167
Comments
When the URL starts with double slash it's a Protocol-relative url. In your example, |
@reynir : That means
It shouldn't call https://github.com/aantron/dream/blob/master/src/pure/formats.ml#L168 |
I think calling I think I found a bug, though: # Uri.make ~path:"//aaa/bbb" () |> Uri.to_string;;
- : string = "//aaa/bbb" (I'm not sure you can actually represent such a URL) |
The doc says: (** Parse a URI string literal into a URI structure. A bare string will be
interpreted as a path; a string prefixed with `//` will be interpreted as a
host.
*)
val of_string : string -> t Maybe, interpretation as a host should be optional? |
The issue is that we know from the context, in Dream, that we are dealing with only a path and query string and there definitely isn't a hostname present. In other words, it's possible for a URI like let () =
let uri = Uri.of_string "//hostname//path/with/double/slashes?query&more" in
print_endline (Uri.path uri);
print_endline (Uri.verbatim_query uri |> Option.get)
let () =
(* Starting from a partial URI where the hostname has already been stripped. *)
let uri = Uri.of_string "//path/with/double/slashes?query&more" in
print_endline (Uri.path uri);
print_endline (Uri.verbatim_query uri |> Option.get) Output:
|
We have a test case in Dream that observes this (see aantron/dream#248 (comment)). |
I believe the behaviour of
Uri.path
is wrong when it is passed a Uri beginning with exactly two slashes. In such case, it drops everything before the third slashThe text was updated successfully, but these errors were encountered: