如果我创建这样的 URL:
guard var urlComponents = URLComponents(url: "https://example.com/something", resolvingAgainstBaseURL: false) else {
return
}
let queryItems = URLQueryItem(name: "token", value: token)
urlComponents.queryItems = [queryItems]
guard let urlWithQueryItem = urlComponents.url else {
return
}
我希望最终结果类似于https://example.com/something#token=7as78f6asd678768asd768asd678
而不是默认的https://example.com/something?token=7as78f6asd678768asd768asd678
(我正在寻找比搜索和替换 ? 字符更智能的东西)
谢谢