Skip to content

Instantly share code, notes, and snippets.

Created August 24, 2018 19:33
What would you like to do?
struct TwilioEncoding: ParameterEncoding {
static var totallyNormal = TwilioEncoding()
// Twilio requires this weird encoding for arrays
func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
var request = try URLEncoding().encode(urlRequest, with: parameters)
if let data = request.httpBody, let string = String(data: data, encoding: .utf8) {
let replaced = string.replacingOccurrences(of: "%5B%5D=", with: "=")
request.httpBody = .utf8)
return request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment