Merge branch 'bugfix/PRODDEF-21579' into 'develop'
Removed characters from urlQueryAllowed characterSet ### Summary Make removing the incoming percent encoding optional via shouldRemoveDefaultEncoding. ```swift If urlQuery value contains '/' , ':' these characters are passed without encoding, due to this we are seeing inconsistent behaviour. For Eg: value contains a url: https://vzwsso/executeTask Expected: https%3A%2F%2Fvzwsso%2FexecuteTask Current: https://vzwsso/executeTask So removed possible characters from urlQueryAllowed characterSet. ``` ### JIRA Ticket PRODDEF-21579 Co-authored-by: Krishna Kishore Bandaru <krishna.kishore.bandaru@verizon.com> Co-authored-by: Keerthy <keerthy.marakanti@verizon.com> See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core/-/merge_requests/311
This commit is contained in:
commit
c636cc1ca4
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user