Skip to content

Allow URLParser to be called directly from ObjC #1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/FoundationEssentials/URL/URLComponents_ObjC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ extension NSURLComponents {
guard let components = URLComponents(string: string, encodingInvalidCharacters: encodingInvalidCharacters) else { return nil }
return _NSSwiftURLComponents(components: components)
}

static func _parseString(_ string: String, encodingInvalidCharacters: Bool, compatibility: URLParserCompatibility.RawValue) -> String? {
return RFC3986Parser.parse(urlString: string, encodingInvalidCharacters: encodingInvalidCharacters, compatibility: .init(rawValue: compatibility))?.urlString
}
}

#if canImport(_FoundationICU)
Expand Down
2 changes: 1 addition & 1 deletion Sources/FoundationEssentials/URL/URLParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ internal struct RFC3986Parser: URLParserProtocol {
}
}

return parse(urlString: finalURLString)
return parse(urlString: finalURLString, compatibility: compatibility)
}

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