Skip to content

IPv6 hosts are not correctly represented in the URI module #881

@ahankinson

Description

@ahankinson

When working on this issue:

gleam-lang/httpc#34

and the ensuing discussion on Discord:

https://discord.com/channels/768594524158427167/1440650512319119490

@Nicd identified that the current behaviour of the stdlib uri module is not correct when parsing IPv6 addresses that are given in the URI.

  let assert Ok(u) = uri.parse("http://[2600:1406:bc00:53::b81e:94c8]")
  let us = uri.to_string(u)
  echo u
  echo us

Produces:

Uri(Some("http"), None, Some("2600:1406:bc00:53::b81e:94c8"), None, "", None, None)
"http://2600:1406:bc00:53::b81e:94c8/"

When the expected output should be:

Uri(Some("http"), None, Some("[2600:1406:bc00:53::b81e:94c8]"), None, "", None, None)
"http://[2600:1406:bc00:53::b81e:94c8]/"

(Note the brackets around the IPv6 addresses.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions