Skip to content

Commit 390142a

Browse files
committed
Fix value in query with value containing '='
Fix missing / into url path when performing action
1 parent 03ef410 commit 390142a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CallbackURLKit/Extensions.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,24 @@ extension String {
2929
let pairs: [String] = self.componentsSeparatedByString("&")
3030
for pair in pairs {
3131
var comps: [String] = pair.componentsSeparatedByString("=")
32-
if comps.count == 2 {
33-
result[comps[0]] = comps[1].stringByRemovingPercentEncoding
32+
if comps.count >= 2 {
33+
let key = comps[0]
34+
let value = comps.dropFirst().joinWithSeparator("=")
35+
result[key] = value.stringByRemovingPercentEncoding
3436
}
3537
}
3638
return result
3739
}
40+
3841
}
3942

4043
extension Dictionary {
4144

4245
var query: String {
4346
var parts = [String]()
4447
for (key, value) in self {
45-
let keyString = "\(key)".stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())
46-
let valueString = "\(value)".stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())
48+
let keyString = "\(key)".stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
49+
let valueString = "\(value)".stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
4750
let query = "\(keyString)=\(valueString)"
4851
parts.append(query)
4952
}

CallbackURLKit/Request.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct Request {
4040
let components = NSURLComponents()
4141
components.scheme = self.client.URLScheme
4242
components.host = kXCUHost
43-
components.path = self.action
43+
components.path = "/\(self.action)"
4444
components.query = (parameters + query).query
4545
return components
4646
}

0 commit comments

Comments
 (0)