Skip to content

Commit 309d460

Browse files
authored
(141225066) Add linked-on-or-after check for empty URL.host() (#1092)
1 parent 0b54163 commit 309d460

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/FoundationEssentials/URL/URL.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,16 @@ public struct URL: Equatable, Sendable, Hashable {
12361236
return nil
12371237
}
12381238

1239+
#if FOUNDATION_FRAMEWORK
1240+
// Linked-on-or-after check for apps which expect .host() to return nil
1241+
// for URLs like "https:///". The new .host() implementation returns
1242+
// an empty string because according to RFC 3986, a host always exists
1243+
// if there is an authority component, it just might be empty.
1244+
if Self.compatibility2 && encodedHost.isEmpty {
1245+
return nil
1246+
}
1247+
#endif
1248+
12391249
func requestedHost() -> String? {
12401250
let didPercentEncodeHost = hasAuthority ? _parseInfo.didPercentEncodeHost : _baseParseInfo?.didPercentEncodeHost ?? false
12411251
if percentEncoded {

0 commit comments

Comments
 (0)