User agent browser detection

Write codeEasy15 min

Your task

Extract the browser family and major version from a simplified User-Agent string. Look for the first token of the form Name/Version where Name is one of Chrome, Firefox, Safari, or Edge and Version starts with an integer major number. Return [name, major_version] with major_version as an int. If no recognized browser token is found, return ["unknown", -1].

Examples

parse_user_agent(ua: str) -> list
Example 1
Inputparse_user_agent("Mozilla/5.0 Chrome/118.0.5993.88 Safari/537.36")
Output["Chrome", 118]