mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Add user agent check to frontend (#955)
* Add user agent check to frontend * Remove auto generated comment.
This commit is contained in:
parent
9c6d28fbc4
commit
3fbd5e351e
@ -1,8 +1,31 @@
|
||||
"""AUTO-GENERATED. DO NOT MODIFY"""
|
||||
"""Frontend for Home Assistant."""
|
||||
import os
|
||||
from user_agents import parse
|
||||
|
||||
FAMILY_MIN_VERSION = {
|
||||
'Chrome': 54, # Object.values
|
||||
'Chrome Mobile': 54,
|
||||
'Firefox': 47, # Object.values
|
||||
'Firefox Mobile': 47,
|
||||
'Opera': 41, # Object.values
|
||||
'Edge': 14, # Array.prototype.includes added in 14
|
||||
'Safari': 10, # Many features not supported by 9
|
||||
}
|
||||
|
||||
|
||||
def where():
|
||||
"""Return path to the frontend."""
|
||||
return os.path.dirname(__file__)
|
||||
|
||||
|
||||
def version(useragent):
|
||||
"""Get the version for given user agent."""
|
||||
useragent = parse(useragent)
|
||||
|
||||
# on iOS every browser is a Safari which we support from version 11.
|
||||
if useragent.os.family == 'iOS':
|
||||
# Was >= 10, temp setting it to 12 to work around issue #11387
|
||||
return useragent.os.version[0] >= 12
|
||||
|
||||
version = FAMILY_MIN_VERSION.get(useragent.browser.family)
|
||||
return version and useragent.browser.version[0] >= version
|
||||
|
Loading…
x
Reference in New Issue
Block a user