ocaml-uri icon indicating copy to clipboard operation
ocaml-uri copied to clipboard

Add support for IPv6 litteral addresses

Open vbmithr opened this issue 12 years ago • 8 comments

http://[::1] can be transformed from and to string for example.

vbmithr avatar Sep 02 '13 18:09 vbmithr

I think @mor1 made some progress on an ipv6 parser in ocaml...

avsm avatar Oct 15 '13 10:10 avsm

somewhere. wasn't complete though. can't recall if it was in the repo or not. i'll have a look...

mor1 avatar Oct 16 '13 20:10 mor1

related to mirage/ocaml-ipaddr#9

avsm avatar Jan 16 '14 14:01 avsm

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.

dsheets avatar Jan 16 '14 15:01 dsheets

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 

avsm avatar Jun 16 '14 16:06 avsm

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...

dsheets avatar Jun 16 '14 16:06 dsheets

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"

edwintorok avatar Jul 05 '23 13:07 edwintorok

https://github.com/mirage/ocaml-uri/pull/169

anmonteiro avatar Jul 05 '23 14:07 anmonteiro