-
-
Save rodericj/ad666156a743bd476c2d5c195e31e7fc 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://fakenews.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