1.指定支付encoding
["/","=","?","&"].forEach({ (char) in
let custom = CharacterSet(charactersIn: char).inverted
lastPath = lastPath.addingPercentEncoding(withAllowedCharacters: custom) ?? ""
})
2.指定字符不被encoding
var charSet = CharacterSet.urlQueryAllowed
["#"].forEach({ (char) in
charSet.insert(charactersIn: char)
})
url = url.addingPercentEncoding(withAllowedCharacters: charSet)!
网友评论