Created
July 26, 2016 21:18
-
-
Save below/15bb184ea100326bdb96cdacf6af67f6 to your computer and use it in GitHub Desktop.
Why is NSQueryItem not percent escaping "+" in a query?
This file contains hidden or 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 UIKit | |
| let comps = NSURLComponents(string: "https://example.com") | |
| comps?.queryItems = [NSURLQueryItem(name: "foobar", value: "foo+bar&something else")] | |
| comps!.URL! | |
| // Actual result: | |
| // https://example.com?foobar=foo+bar%26something%20else | |
| // As per https://tools.ietf.org/html/rfc3986#section-2.1 it | |
| // appears that '+' should be escaped. What am I overlooking? |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While "+" is legal, some systems mess it up. So therefore, here is the solution: http://stackoverflow.com/questions/31577188/how-to-encode-into-2b-with-nsurlcomponents/37314144#37314144