Skip to content

Parsing of IPv6 addresses seems to incorrectly include []s #770

@jszwedko

Description

@jszwedko
  • Note that this crate implements the URL Standard not RFC 1738 or RFC 3986

Describe the bug

Hi all!

It seems like parsing a URL that contains an IPv6 address like http://[::1] returns a Url struct that, when .host().unwrap.to_string() is called on it, returns [::1] where the docs state, for Host:

An IPv6 address. Url::host_str returns the serialization of that address between [ and ] brackets, in the format per RFC 5952 A Recommendation for IPv6 Address Text Representation: lowercase hexadecimal with maximal :: compression.

The "between" language here makes me think that it should not be including the [].

According to the linked URL Standard, it also states, for host parsing, that:

If input starts with U+005B ([), then:

If input does not end with U+005D (]), validation error, return failure.

Return the result of IPv6 parsing input with its leading U+005B ([) and trailing U+005D (]) removed.

Which makes it seem like the [] should be removed.

I'm just curious to get more clarity on expected behavior here.

This came up due to some confusion in nats-io/nats.rs#386

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions