`split_target` over string beginning with exactly two slashes
I believe the behaviour of split_target is wrong when it is passed a string which begins with exactly two slashes:
>utop-full -require digestif.c
utop # #require "dream";;
utop # Dream.split_target "aaa/bbb/ccc";;
- : string * string = ("aaa/bbb/ccc", "")
utop # Dream.split_target "/aaa/bbb/ccc";;
- : string * string = ("/aaa/bbb/ccc", "")
utop # Dream.split_target "//aaa/bbb/ccc";; (* Boom! *)
- : string * string = ("/bbb/ccc", "")
utop # Dream.split_target "///aaa/bbb/ccc";;
- : string * string = ("/aaa/bbb/ccc", "")
utop # Dream.split_target "////aaa/bbb/ccc";;
- : string * string = ("//aaa/bbb/ccc", "")
utop # Dream.split_target "/////aaa/bbb/ccc";;
- : string * string = ("///aaa/bbb/ccc", "")
Maybe an upstream issue:
- https://github.com/mirage/ocaml-uri/issues/167
- https://github.com/aantron/dream/blob/master/src/pure/formats.ml#L168
It's probably related to
https://github.com/aantron/dream/blob/599efd55fc5d0f0f3fbe776fd2ba6b17f6aeca8d/test/expect/pure/formats/target/target.ml#L19-L22
and the test's output
https://github.com/aantron/dream/blob/599efd55fc5d0f0f3fbe776fd2ba6b17f6aeca8d/test/expect/pure/formats/target/target.ml#L37
and may be an upstream issue indeed. I am looking into this now. Ultimately, it should be possible to work around it by reimplementing it, even if it turns out to be an issue in Uri.
I've left a detailed comment about this in the issue you opened, https://github.com/mirage/ocaml-uri/issues/167 (thanks for that). I suggest we wait to see if there is a fix for this in ocaml-uri soon. If not, we can work around it in Dream for the next release.