Created
April 17, 2018 06:21
-
-
Save ratulSharker/e3ad4bc7d9f5a81b939d753edc017c96 to your computer and use it in GitHub Desktop.
Extension for creating URL using non-supporting character like (whitespaces / unicode) etc.
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
// | |
// URL+PercentEncoding.swift | |
// | |
// Created by ratul sharker on 4/4/18. | |
// | |
import Foundation | |
extension URL { | |
static func initWithPercentEncoding(string : String) -> URL? { | |
let encodedString = string.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed) | |
if let encodedString = encodedString { | |
return URL.init(string: encodedString) | |
} else { | |
return nil | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment