Properly encoded the url query part. This broke some time ago.

This commit is contained in:
Damiano Galassi committed 2017-08-05 10:05:45 +02:00
1 parent 8faafc861e
commit 0723ebdf2e
1 file changed
+7 -1
+7 -1
View File
@@ -9,10 +9,16 @@ import Foundation
// MARK: - URL Utilities
private let allowedChars: CharacterSet = {
var chars = CharacterSet.urlQueryAllowed
chars.remove(charactersIn: "&+=?")
return chars
}()
extension String {
func urlEncoded() -> String {
return self.precomposedStringWithCompatibilityMapping.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) ?? ""
return self.precomposedStringWithCompatibilityMapping.addingPercentEncoding(withAllowedCharacters: allowedChars) ?? ""
}
}