mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
user_agent: Use re.X to make the regex a little more readable.
This commit is contained in:
@@ -5,6 +5,10 @@ from typing import Dict
|
||||
# zerver/tests/test_decorators.py
|
||||
# And extend zerver/tests/fixtures/user_agents_unique with any new test cases
|
||||
def parse_user_agent(user_agent: str) -> Dict[str, str]:
|
||||
match = re.match("^(?P<name>[^/ ]*[^0-9/(]*)(/(?P<version>[^/ ]*))?([ /].*)?$", user_agent)
|
||||
match = re.match(
|
||||
"""^ (?P<name> [^/ ]* [^0-9/(]* )
|
||||
(/ (?P<version> [^/ ]* ))?
|
||||
([ /] .*)?
|
||||
$""", user_agent, re.X)
|
||||
assert match is not None
|
||||
return match.groupdict()
|
||||
|
||||
Reference in New Issue
Block a user