Skip to content

Instantly share code, notes, and snippets.

@markvanwijnen
Last active March 8, 2021 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markvanwijnen/b756178219342482dfb6b61e61b01043 to your computer and use it in GitHub Desktop.
Save markvanwijnen/b756178219342482dfb6b61e61b01043 to your computer and use it in GitHub Desktop.
extension String {
var urlQueryItems: [URLQueryItem]? {
URLComponents(string: "://?\(self)")?.queryItems
}
}
extension Array where Element == URLQueryItem {
func value(for name: String) -> String? {
return self.filter({$0.name == name}).first?.value
}
subscript(name: String) -> String? {
return value(for: name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment