Skip to content

Commit 2966e02

Browse files
authored
(134231086) URL.host should not return percent-encoded host (#875)
1 parent 843bf80 commit 2966e02

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Sources/FoundationEssentials/URL/URL.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ public struct URL: Equatable, Sendable, Hashable {
11881188
return _url.host
11891189
}
11901190
#endif
1191-
return host()
1191+
return host(percentEncoded: false)
11921192
}
11931193

11941194
/// Returns the host component of the URL if present, otherwise returns `nil`.

Tests/FoundationEssentialsTests/URLTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,11 @@ final class URLTests : XCTestCase {
622622
XCTAssertEqual(url.path(), "/my/non/existent/path")
623623
}
624624

625+
func testURLHostRetainsIDNAEncoding() throws {
626+
let url = URL(string: "ftp://user:password@*.xn--poema-9qae5a.com.br:4343/cat.txt")!
627+
XCTAssertEqual(url.host, "*.xn--poema-9qae5a.com.br")
628+
}
629+
625630
func testURLComponentsPercentEncodedUnencodedProperties() throws {
626631
var comp = URLComponents()
627632

0 commit comments

Comments
 (0)