Just
Just copied to clipboard
Have you thought about using URLQueryItem for building the query components?
https://developer.apple.com/reference/foundation/urlqueryitem
For example to format https://domain.com/test?filename=test.pdf&title=hello
var components = URLComponents(string: "https://domain.com/test")
components?.queryItems = [
URLQueryItem(name: "filename", value: "file.pdf"),
URLQueryItem(name: "title", value: "hello")]
let url = components?.url