Files
zulip/zerver/lib/user_agent.py
Tim Abbott 5c9def5be4 Add script to parse user agents with historical data set.
(imported from commit e529c0b914ed3d3d06e9581a6239676f68c97b3f)
2013-12-13 11:26:36 -05:00

11 lines
368 B
Python

import re
# Warning: If you change this parsing, please test using
# tools/test_user_agent_parsing.py
# And extend tools/user_agents_unique with any new test cases
def parse_user_agent(user_agent):
match = re.match("^(?P<name>[^/ ]*[^0-9/(]*)(/(?P<version>[^/ ]*))?([ /].*)?$", user_agent)
if match is None:
return None
return match.groupdict()