diff --git a/Sources/SmartyStreets/SmartyRequest.swift b/Sources/SmartyStreets/SmartyRequest.swift index 3ce788d..81e397e 100644 --- a/Sources/SmartyStreets/SmartyRequest.swift +++ b/Sources/SmartyStreets/SmartyRequest.swift @@ -54,7 +54,9 @@ public class SmartyRequest { } func urlEncode(value: String) -> String { - return value.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)! + var allowedCharacters = CharacterSet.urlPathAllowed + allowedCharacters.remove(charactersIn: USAutocompleteProClient.arrayItemsSeparator) + return value.addingPercentEncoding(withAllowedCharacters: allowedCharacters)! } func setPayload(payload:Data) { diff --git a/Sources/SmartyStreets/USAutocompletePro/USAutocompleteProClient.swift b/Sources/SmartyStreets/USAutocompletePro/USAutocompleteProClient.swift index 00c417f..de0faaf 100644 --- a/Sources/SmartyStreets/USAutocompletePro/USAutocompleteProClient.swift +++ b/Sources/SmartyStreets/USAutocompletePro/USAutocompleteProClient.swift @@ -2,7 +2,9 @@ import Foundation public class USAutocompleteProClient: NSObject { // It is recommended to instantiate this class using SSClientBuilder - + + static let arrayItemsSeparator = ";" + var sender:SmartySender public var serializer:SmartySerializer @@ -65,6 +67,6 @@ public class USAutocompleteProClient: NSObject { return String() } - return list.joined(separator: ";") + return list.joined(separator: Self.arrayItemsSeparator) } } diff --git a/Tests/SmartyStreetsTests/SmartyRequestTests.swift b/Tests/SmartyStreetsTests/SmartyRequestTests.swift index e964ffb..8a5169f 100644 --- a/Tests/SmartyStreetsTests/SmartyRequestTests.swift +++ b/Tests/SmartyStreetsTests/SmartyRequestTests.swift @@ -44,4 +44,10 @@ class SmartyRequestTests: XCTestCase { XCTAssertEqual(url, "https://fakesearch.com/lookup?street=Parks%20Blvd") } + func testGetURLWithURLEncodedArray() { + smartyRequest.urlPrefix = "https://fakesearch.com/lookup?" + smartyRequest.setValue(value: "abc;def", HTTPParameterField: "array") + let url = smartyRequest.getUrl() + XCTAssertEqual(url, "https://fakesearch.com/lookup?array=abc%3Bdef") + } }