Skip to content

Commit 8c3b506

Browse files
committed
removed auto percent escaping of url parameters
Signed-off-by: James Hall <[email protected]>
1 parent b82eb44 commit 8c3b506

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

Sources/WebRequest/Delivery/HTTPWebRequestDelivery.swift

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,13 @@ open class HTTPWebRequestDelivery : NSObject, WebRequestDelivery {
4444

4545
if (pathComponents.count > 1) {
4646
let queryComponents = pathComponents[1].components(separatedBy: "&")
47+
urlComponents.queryItems = queryComponents
48+
.map {
49+
let keyVal = $0.components(separatedBy: "=")
50+
return URLQueryItem(name: keyVal.first ?? "", value: keyVal.last ?? "") }
51+
} else if let urlParams = request.urlParameters {
4752
urlComponents.queryItems =
48-
queryComponents
49-
.map {
50-
let keyVal = $0.components(separatedBy: "=")
51-
return URLQueryItem(name: WebRequest.urlEncode(keyVal.first ?? ""),
52-
value: WebRequest.urlEncode(keyVal.last ?? "")) }
53-
}
54-
else if let urlParams = request.urlParameters {
55-
urlComponents.queryItems =
56-
urlParams
57-
.map { URLQueryItem(name: WebRequest.urlEncode($0.key),
58-
value: WebRequest.urlEncode($0.value)) }
53+
urlParams.map { URLQueryItem(name: $0.key, value: $0.value) }
5954
}
6055

6156
return urlComponents.url
@@ -146,7 +141,7 @@ open class HTTPWebRequestDelivery : NSObject, WebRequestDelivery {
146141
let result = WebRequest.Result(status: status, headers: headers, data: data)
147142
try request.completion?(result, request)
148143
}
149-
144+
150145
open func onDataReceived(request: WebRequest, status: Int, percentComplete: Int, target: URL ) throws {
151146
let result = WebRequest.Result(status: status, headers: [:] , data: nil)
152147
try request.onDataReceived?(result, request, percentComplete, target);

0 commit comments

Comments
 (0)