diff --git a/ios/Capacitor/Capacitor/Plugins/CapacitorHttp.swift b/ios/Capacitor/Capacitor/Plugins/CapacitorHttp.swift index 6def38d2a6..4745718667 100644 --- a/ios/Capacitor/Capacitor/Plugins/CapacitorHttp.swift +++ b/ios/Capacitor/Capacitor/Plugins/CapacitorHttp.swift @@ -3,10 +3,6 @@ import Foundation @objc(CAPHttpPlugin) public class CAPHttpPlugin: CAPPlugin { @objc func http(_ call: CAPPluginCall, _ httpMethod: String?) { - // Protect against bad values from JS before calling request - guard let url = call.getString("url") else { return call.reject("Must provide a URL"); } - guard var _ = URL(string: url) else { return call.reject("Invalid URL"); } - do { try HttpRequestHandler.request(call, httpMethod, self.bridge?.config) } catch let error { diff --git a/ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift b/ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift index d12f2fc14e..a155990c16 100644 --- a/ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift +++ b/ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift @@ -141,7 +141,7 @@ class HttpRequestHandler { } public static func request(_ call: CAPPluginCall, _ httpMethod: String?, _ config: InstanceConfiguration?) throws { - guard let urlString = call.getString("url") else { throw URLError(.badURL) } + guard let urlString = call.getString("url")?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else { throw URLError(.badURL) } let method = httpMethod ?? call.getString("method", "GET") // swiftlint:disable force_cast