I want to encode url with percent encoding.
If the value of query parameter is url type, how can I encode?
let urlString = "https://www.google.com/path1?param1=https://www.apple.com/path2?param2=asdf"
print(urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed))
// https://www.google.com/path1?param1=https://www.apple.com/path2?param2=asdf
// It is not encoded.
I think, my expectation is below.
https://www.google.com/path1?param1=https%3A%2F%2Fwww.apple.com%2Fpath2%3Fparam2%3Dasdf
String? Or do you have the components and is trying to construct aURL?https://example.com?p1=https://foo.bar?p2=x&p3=y? How do you know, whetherp3is a parameter toexample.comorfoo.bar?