Created
February 7, 2018 19:05
-
-
Save gregheo/af0ff17111a2c402fa1e8d838229c61c to your computer and use it in GitHub Desktop.
Fake URL + url encoded query paramaters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let encodedString = "data=%7B%0D%0A%22coffee%22%3A%20%22coffee%22%2C%0D%0A%22beer%22%3A%20%22beer%22%2C%0D%0A%22has_bylaws%22%3A%20true%0D%0A%7D%0D%0A" | |
guard let c = URLComponents(string: "http://fake.com/?" + encodedString) else { | |
fatalError("could not generate url components! :(") | |
} | |
for item in c.queryItems ?? [] { | |
print("Got key \(item.name) with value \(item.value)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment