The reason that he now has a percentage .urlPathAllowed character : is because .urlPathAllowed now strictly complies with RFC 3986 , which says in Section 3.3 "Paths":
In addition, a reference to a URI (section 4.1) can be a reference to a relative path, in which case the first segment of the path cannot contain a colon (":").
Thus : are allowed in relative ways (what we are dealing with here), but simply not in the first component.
To consider:
let string = "foo:bar/baz:qux" print(string.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!)
This, in accordance with RFC 3986, encodes in percent : in the first component, but allows it to be unencoded in the following components:
foo% 3Abar / baz: qux
This character set is not percent encoding solely on the basis of what characters are in the set, but actually applies the logic of the relative path of RFC 3986. But, as Ker said, if you need to, you can bypass this logic, .urlPathAllowed your own character set with the same allowed characters as .urlPathAllowed , and this new character set will not apply this RFC 3986 logic.
source share