diff --git a/MVMCore/MVMCore/Models/JSON/JSONHelper.swift b/MVMCore/MVMCore/Models/JSON/JSONHelper.swift index 857310b..6b4deef 100644 --- a/MVMCore/MVMCore/Models/JSON/JSONHelper.swift +++ b/MVMCore/MVMCore/Models/JSON/JSONHelper.swift @@ -53,7 +53,7 @@ extension JSONDictionary { return string } - public func toUrlQueryItems() throws -> [URLQueryItem] { + public func toUrlQueryItems(shouldRemoveDefaultEncoding: Bool = false) throws -> [URLQueryItem] { var queryItems: [URLQueryItem] = [] for (key, value) in self { var valueString: String @@ -62,10 +62,11 @@ extension JSONDictionary { } else if let value = value as? JSONArray { valueString = try value.toJSONString() } else { - guard let baseValueString = String(describing: value.base).removingPercentEncoding else { - throw JSONError.error(message: "query item failed: \(key) value \(value.base)") + valueString = String(describing: value.base) + if shouldRemoveDefaultEncoding { + guard let encodedValue = valueString.removingPercentEncoding else { throw JSONError.error(message:"query item failed: \(key) value \(value.base)") } + valueString = encodedValue } - valueString = baseValueString } let queryItem = URLQueryItem(name: key, value: valueString) queryItems.append(queryItem)