Skip to content

Commit 78fa839

Browse files
authored
(138354331) Add linked-on-or-after check for apps that pass an empty URL string (#1042)
1 parent e43505c commit 78fa839

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/FoundationEssentials/URL/URL.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,14 @@ public struct URL: Equatable, Sendable, Hashable {
779779
_url = URL._converted(from: inner)
780780
return
781781
}
782+
// Linked-on-or-after check for apps which pass an empty string.
783+
// The new URL(string:) implementations allow the empty string
784+
// as input since an empty path is valid and can be resolved
785+
// against a base URL. This is shown in the RFC 3986 examples:
786+
// https://datatracker.ietf.org/doc/html/rfc3986#section-5.4.1
787+
if Self.compatibility1 && string.isEmpty {
788+
return nil
789+
}
782790
#endif // FOUNDATION_FRAMEWORK
783791
guard let parseInfo = Parser.parse(urlString: string, encodingInvalidCharacters: true) else {
784792
return nil

0 commit comments

Comments
 (0)