Skip to content

Commit 4b8d3b0

Browse files
authored
(142639765) Allow URLParser to be called directly from ObjC (#1118)
1 parent 5ed6c72 commit 4b8d3b0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Sources/FoundationEssentials/URL/URLComponents_ObjC.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ extension NSURLComponents {
3333
guard let components = URLComponents(string: string, encodingInvalidCharacters: encodingInvalidCharacters) else { return nil }
3434
return _NSSwiftURLComponents(components: components)
3535
}
36+
37+
static func _parseString(_ string: String, encodingInvalidCharacters: Bool, compatibility: URLParserCompatibility.RawValue) -> String? {
38+
return RFC3986Parser.parse(urlString: string, encodingInvalidCharacters: encodingInvalidCharacters, compatibility: .init(rawValue: compatibility))?.urlString
39+
}
3640
}
3741

3842
#if canImport(_FoundationICU)

Sources/FoundationEssentials/URL/URLParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ internal struct RFC3986Parser: URLParserProtocol {
699699
}
700700
}
701701

702-
return parse(urlString: finalURLString)
702+
return parse(urlString: finalURLString, compatibility: compatibility)
703703
}
704704

705705
/// Parses a URL string into its component parts and stores these ranges in a `URLParseInfo`.

0 commit comments

Comments
 (0)