Created
June 17, 2020 03:39
-
-
Save stleamist/66e3dc0dfbbd917a651dae7e133f0713 to your computer and use it in GitHub Desktop.
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 Foundation | |
extension URL { | |
init?(string: String?) { | |
guard let string = string else { | |
return nil | |
} | |
self.init(string: string) | |
} | |
static func percentEncoded(string: String?) -> URL? { | |
self.init(string: string?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment