Skip to content

Commit

Permalink
Refactoring (#184)
Browse files Browse the repository at this point in the history
* Tiny fixes and improvements (#182)

* fixes for deprecations

* made changes for URL encoding

* refactored parameter encoding

* Run SwiftFormat

* Rename variable
  • Loading branch information
3lvis authored Jan 26, 2017
1 parent f847a65 commit 9c9e82c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/Dictionary+FormURLEncoded.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public extension Dictionary where Key: ExpressibleByStringLiteral {
*/
public func urlEncodedString() throws -> String {

let pairs = try self.reduce([]) { current, kvPair -> [String] in
if let encodedValue = "\(kvPair.value)".addingPercentEncoding(withAllowedCharacters: .urlQueryParametersAllowed) {
return current + ["\(kvPair.key)=\(encodedValue)"]
let pairs = try self.reduce([]) { current, keyValuePair -> [String] in
if let encodedValue = "\(keyValuePair.value)".addingPercentEncoding(withAllowedCharacters: .urlQueryParametersAllowed) {
return current + ["\(keyValuePair.key)=\(encodedValue)"]
} else {
throw NSError(domain: Networking.domain, code: 0, userInfo: [NSLocalizedDescriptionKey: "Couldn't encode \(kvPair.value)"])
throw NSError(domain: Networking.domain, code: 0, userInfo: [NSLocalizedDescriptionKey: "Couldn't encode \(keyValuePair.value)"])
}
}

Expand Down

0 comments on commit 9c9e82c

Please sign in to comment.