ocaml-uri
ocaml-uri copied to clipboard
Add support for IPv6 litteral addresses
http://[::1] can be transformed from and to string for example.
I think @mor1 made some progress on an ipv6 parser in ocaml...
somewhere. wasn't complete though. can't recall if it was in the repo or not. i'll have a look...
related to mirage/ocaml-ipaddr#9
I thought a pretty minimal regex parser for this made it in a while ago...
This will happen after it gets into ocaml-ipaddr which will take it to 2.0. Then, ocaml-ipaddr will become a dep of ocaml-uri when The Coming Reckoning finally fixes the Uri interface in 2.0.
This works pretty well with Ipaddr atm; do we really need it in URI?
Ipaddr.of_string (match Uri.host (Uri.of_string "http://[::1]") with |Some i -> i |None -> failwith "");;
- : Ipaddr.t option = Some ::1
I think there is some place for a type that sums addresses and host names. End users shouldn't (necessarily) have to consider that the host string that they get back may not need name resolution. I was imagining something like:
type host = Ipaddr of Ipaddr.t | Host of string
val host : t -> host option
val host_string : t -> string option
where host_string is the present host. Perhaps this is unnecessary, though, as you indicate...
Did 'Uri' regress this behaviour? The example from above https://github.com/mirage/ocaml-uri/issues/23#issuecomment-46202419 no longer works, it doesn't parse RFC conforming IPv6 addresses anymore:
utop # Uri.of_string "http://[::1]" |> Uri.host;;
- : string option = Some ""
utop # Uri.of_string "http://[::1]" |> Uri.path;;
- : string = "%5B::1%5D"
https://github.com/mirage/ocaml-uri/pull/169