mirror of https://github.com/zulip/zulip.git
get_device_browser: Fix Opera detection.
Starting from version 15, Opera uses 'OPR/' in its user agent string. We need to move Opera detection before Chrome detection because Opera's user agent string satisfies Chrome conditions as well. Ref: https://dev.opera.com/blog/opera-user-agent-strings-opera-15-and-beyond/
This commit is contained in:
parent
14402b0b97
commit
6357737978
|
@ -15,6 +15,8 @@ def get_device_browser(user_agent):
|
|||
user_agent = user_agent.lower()
|
||||
if "edge" in user_agent:
|
||||
return "Edge"
|
||||
elif "opera" in user_agent or "opr/" in user_agent:
|
||||
return "Opera"
|
||||
elif "chrome" in user_agent and "chromium" not in user_agent:
|
||||
return 'Chrome'
|
||||
elif "firefox" in user_agent and "seamonkey" not in user_agent and "chrome" not in user_agent:
|
||||
|
@ -23,8 +25,6 @@ def get_device_browser(user_agent):
|
|||
return "Chromium"
|
||||
elif "safari" in user_agent and "chrome" not in user_agent and "chromium" not in user_agent:
|
||||
return "Safari"
|
||||
elif "opera" in user_agent:
|
||||
return "Opera"
|
||||
elif "msie" in user_agent or "trident" in user_agent:
|
||||
return "Internet Explorer"
|
||||
elif "zulip" in user_agent:
|
||||
|
|
|
@ -89,6 +89,9 @@ class TestBrowserAndOsUserAgentStrings(ZulipTestCase):
|
|||
'Version/10.0.2 Safari/602.3.12', 'Safari', 'MacOS'),
|
||||
('ZulipAndroid/1.0', 'Zulip', 'Android'),
|
||||
('ZulipMobile/1.0', 'Zulip', None),
|
||||
('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 '
|
||||
'(KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 '
|
||||
'OPR/15.0.1147.100', 'Opera', 'Windows'),
|
||||
('Mozilla/5.0 (Windows NT 10.0; <64-bit tags>) AppleWebKit/'
|
||||
'<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Safari'
|
||||
'/<WebKit Rev> Edge/<EdgeHTML Rev>.'
|
||||
|
|
Loading…
Reference in New Issue