Account for User-Agent being non-existent, causing a TypeError (#11064)

* Account for User-Agent being non-existent, causing a TypeError

* Actually fix case of no user-agent with last resort

* Return es5 as last resort

* Update __init__.py

* Update __init__.py
This commit is contained in:
Trevor Joynson 2018-01-02 16:42:41 -08:00 committed by Paulus Schoutsen
parent 02c3ea1917
commit 86e1d0f952

View File

@ -579,8 +579,12 @@ def _is_latest(js_option, request):
if js_option != 'auto':
return js_option == 'latest'
useragent = request.headers.get('User-Agent')
if not useragent:
return False
from user_agents import parse
useragent = parse(request.headers.get('User-Agent'))
useragent = parse(useragent)
# on iOS every browser is a Safari which we support from version 10.
if useragent.os.family == 'iOS':