diff --git a/Sources/FoundationEssentials/URL/URL.swift b/Sources/FoundationEssentials/URL/URL.swift index a9de54281..9e2dd5677 100644 --- a/Sources/FoundationEssentials/URL/URL.swift +++ b/Sources/FoundationEssentials/URL/URL.swift @@ -1188,7 +1188,7 @@ public struct URL: Equatable, Sendable, Hashable { return _url.host } #endif - return host() + return host(percentEncoded: false) } /// Returns the host component of the URL if present, otherwise returns `nil`. diff --git a/Tests/FoundationEssentialsTests/URLTests.swift b/Tests/FoundationEssentialsTests/URLTests.swift index b3b420076..d1b434521 100644 --- a/Tests/FoundationEssentialsTests/URLTests.swift +++ b/Tests/FoundationEssentialsTests/URLTests.swift @@ -622,6 +622,11 @@ final class URLTests : XCTestCase { XCTAssertEqual(url.path(), "/my/non/existent/path") } + func testURLHostRetainsIDNAEncoding() throws { + let url = URL(string: "ftp://user:password@*.xn--poema-9qae5a.com.br:4343/cat.txt")! + XCTAssertEqual(url.host, "*.xn--poema-9qae5a.com.br") + } + func testURLComponentsPercentEncodedUnencodedProperties() throws { var comp = URLComponents()