Skip to content

Instantly share code, notes, and snippets.

Last active Jan 2, 2017
What would you like to do?
URL swift extension to get query parameter values array (adapted from
import Foundation
extension URL {
func queryItemValues(key: String) -> [String?]? {
guard let components = NSURLComponents(url: self, resolvingAgainstBaseURL: false) else {
return nil
guard let queryItems = components.queryItems else { return nil }
return queryItems.filter {
$ == key
}.map {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment