Skip to content

Commit 402b90e

Browse files
authored
(134231086) URL.host should not return percent-encoded host (#902) (#939)
1 parent ada683d commit 402b90e

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
@@ -571,6 +571,11 @@ final class URLTests : XCTestCase {
571571
XCTAssertEqual(appended.relativePath, "relative/with:slash")
572572
}
573573

574+
func testURLHostRetainsIDNAEncoding() throws {
575+
let url = URL(string: "ftp://user:password@*.xn--poema-9qae5a.com.br:4343/cat.txt")!
576+
XCTAssertEqual(url.host, "*.xn--poema-9qae5a.com.br")
577+
}
578+
574579
func testURLComponentsPercentEncodedUnencodedProperties() throws {
575580
var comp = URLComponents()
576581

0 commit comments

Comments
 (0)