Skip to content

Commit fb88623

Browse files
committed
(134231086) URL.host should not return percent-encoded host
1 parent e905df1 commit fb88623

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
@@ -586,6 +586,11 @@ final class URLTests : XCTestCase {
586586
XCTAssertEqual(url.fileSystemPath, "/path/slashes")
587587
}
588588

589+
func testURLHostRetainsIDNAEncoding() throws {
590+
let url = URL(string: "ftp://user:password@*.xn--poema-9qae5a.com.br:4343/cat.txt")!
591+
XCTAssertEqual(url.host, "*.xn--poema-9qae5a.com.br")
592+
}
593+
589594
func testURLComponentsPercentEncodedUnencodedProperties() throws {
590595
var comp = URLComponents()
591596

0 commit comments

Comments
 (0)