Created
November 18, 2020 03:15
-
-
Save Andy0570/15373d90cb47a4de1d3779024a47b0f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension URL { | |
func withQueries(_ queries: [String: String]) -> URL? { | |
var components = URLComponents(url: self, resolvingAgainstBaseURL: true) | |
components?.queryItems = queries.compactMap { URLQueryItem(name: $0.0, value: $0.1) } | |
return components?.url | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment