Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get Specific URLQueryItem from URLComponents
func queryParam(urlString: String?, param: String) -> String? {
guard let urlString = urlString else { return nil }
guard let urlComponents = URLComponents(string: urlString) else { return nil }
guard let queryItems = urlComponents.queryItems else { return nil }
return queryItems.filter { queryItem in
return == param
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment