This is my simple extension:
extension String {
var urlDecoded: String? {
replacingOccurrences(of: "+", with: "%20").removingPercentEncoding
}
}
And here is my string:
let string = "https%253A%252F%252Fplz.pl"
After I call
let firstDecoded = string.urlDecoded
// "https%3A%2F%2Fplz.pl"
let secondDecoded = string.urlDecoded?.urlDecoded
// "https://plz.pl"
Why do I have to call it twice? How can I do it correctly and quickly?