swift-foundation icon indicating copy to clipboard operation
swift-foundation copied to clipboard

URL.init(string:) handling of unix file paths has changed in Swift 6

Open rnro opened this issue 4 months ago • 1 comments

Initializing a URL from a unix file path in Swift 6 on Linux now returns a non-nil value (an empty String). In earlier Swift versions and on macOS it returns nil.

On Linux Swift 5.10:

  1> import Foundation
  2> let u = Foundation.URL(string: "unix:///tmp/file")
  [snip]
  3> print(u!.host)
nil

On Linux Swift 6.0.1:

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

rnro avatar Oct 02 '24 16:10 rnro