Last active
March 8, 2021 15:21
-
-
Save markvanwijnen/b756178219342482dfb6b61e61b01043 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
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