let path1 = "[path:test]"
var set = CharacterSet()
set.formUnion(.urlPathAllowed)
let encodedPath1 = path1.addingPercentEncoding(withAllowedCharacters: set)
let encodedPath2 = path1.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)
print("Encoded Path 1: \(String(describing: encodedPath1))")
print("Encoded Path 2: \(String(describing: encodedPath2))")
отпечаток (: не закодирован первым.)
Encoded Path 1: Optional("%5Bpath:test%5D")
Encoded Path 2: Optional("%5Bpath%3Atest%5D")
Подробнее здесь: https://stackoverflow.com/questions/791 ... paramaters