Skip to content

Commit

Permalink
fix: Xbox OS detection
Browse files Browse the repository at this point in the history
It is better to detect Xbox devices as having the OS "Xbox".
Otherwise, they are detected as "Windows 10", making it difficult to
see the difference between Legacy Edge on Windows and the Xbox
browser.  (Karma (https://github.com/karma-runner/karma) only shows
the browser & OS on the status line.)

With this change, Xbox 360, Xbox One, Xbox X/S, and Xbox Series X/S
are all detected as OS "Xbox" with version "360", "One", etc.
  • Loading branch information
joeyparrish committed Feb 9, 2021
1 parent 45bf76a commit 7679003
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@

os : [[

// Xbox, consider this before other Windows-based devices
/(xbox);\s+xbox\s([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)

// Windows based
/microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes)
], [NAME, VERSION], [
Expand Down
36 changes: 36 additions & 0 deletions test/os-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,42 @@
"version" : "4"
}
},
{
"desc" : "Xbox 360",
"ua" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox 360) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36",
"expect" :
{
"name" : "Xbox",
"version" : "360"
}
},
{
"desc" : "Xbox One",
"ua" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox One; WebView/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19041",
"expect" :
{
"name" : "Xbox",
"version" : "One"
}
},
{
"desc" : "Xbox X",
"ua" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36 Edge/20.02",
"expect" :
{
"name" : "Xbox",
"version" : "X"
}
},
{
"desc" : "Xbox Series X",
"ua" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox Series X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36 Edge/20.02 ",
"expect" :
{
"name" : "Xbox",
"version" : "Series X"
}
},
{
"desc" : "Mint",
"ua" : "",
Expand Down

0 comments on commit 7679003

Please sign in to comment.