Skip to content

Commit 7679003

Browse files
committed
fix: Xbox OS detection
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.
1 parent 45bf76a commit 7679003

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/ua-parser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@
719719

720720
os : [[
721721

722+
// Xbox, consider this before other Windows-based devices
723+
/(xbox);\s+xbox\s([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)
724+
722725
// Windows based
723726
/microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes)
724727
], [NAME, VERSION], [

test/os-test.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,42 @@
287287
"version" : "4"
288288
}
289289
},
290+
{
291+
"desc" : "Xbox 360",
292+
"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",
293+
"expect" :
294+
{
295+
"name" : "Xbox",
296+
"version" : "360"
297+
}
298+
},
299+
{
300+
"desc" : "Xbox One",
301+
"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",
302+
"expect" :
303+
{
304+
"name" : "Xbox",
305+
"version" : "One"
306+
}
307+
},
308+
{
309+
"desc" : "Xbox X",
310+
"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",
311+
"expect" :
312+
{
313+
"name" : "Xbox",
314+
"version" : "X"
315+
}
316+
},
317+
{
318+
"desc" : "Xbox Series X",
319+
"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 ",
320+
"expect" :
321+
{
322+
"name" : "Xbox",
323+
"version" : "Series X"
324+
}
325+
},
290326
{
291327
"desc" : "Mint",
292328
"ua" : "",

0 commit comments

Comments
 (0)