Skip to content

URL.init(string:) handling of IPv6 addresses has changed in Swift 6 #957

Closed
@rnro

Description

@rnro

Initializing a URL from an IPv6 address in Swift 6 on Linux now does not strip enclosing square-brackets. In earlier Swift versions and on macOS the square-brackets are removed.

As well as being a behavior change this can cause issues when passing the host component on e.g. to inet_pton which doesn't tolerate the square braces.

On Linux Swift 5.10:

  1> import Foundation
  2> let u = Foundation.URL(string: "http://[::1]")
  [snip]
  3> print(u!.host)
Optional("::1")

On Linux Swift 6.0.1:

  1> import Foundation
  2> let u = Foundation.URL(string: "http://[::1]")
  [snip]
  3> print(u!.host)
Optional("[::1]")

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