Skip to content

Commit

Permalink
Parse Headless Chrome versions
Browse files Browse the repository at this point in the history
The initial implementation of the Headless Chrome detection (ua-parser#228) didn't detect
versions of the headless version. This has been fixed.

A test for Ubuntu Chromium in headless mode was also added. I haven't made it
recognized as HeadlessChromium as it has HeadlessChrome in the user agent. It
might be worthwhile to check how a pure compiled from source Chromium behaves.
Nevertheless, this commit is still an improvement.
  • Loading branch information
mgol committed Jul 26, 2017
1 parent 4af9a7e commit 1fb2ed7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions regexes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ user_agent_parsers:

# Headless Chrome
# https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
# Currently only available on Linux
- regex: 'HeadlessChrome'
- regex: '(HeadlessChrome)/(\d+)\.(\d+)(?:\.(\d+))?'
family_replacement: 'HeadlessChrome'

# Browser/major_version.minor_version
Expand Down
14 changes: 10 additions & 4 deletions tests/test_ua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6657,11 +6657,17 @@ test_cases:
minor: '7'
patch: '10'

- user_agent_string: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36'
- user_agent_string: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/60.0.3112.78 Safari/537.36'
family: 'HeadlessChrome'
major:
minor:
patch:
major: '60'
minor: '0'
patch: '3112'

- user_agent_string: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 HeadlessChrome/59.0.3071.109 Safari/537.36'
family: 'HeadlessChrome'
major: '59'
minor: '0'
patch: '3071'

- user_agent_string: 'Roku/DVP-6.2 (096.02E06005A)'
family: 'Roku'
Expand Down

0 comments on commit 1fb2ed7

Please sign in to comment.