From 7679003f87bec9ceff3d0825b67cda1124454a4b Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Tue, 9 Feb 2021 12:12:15 -0800 Subject: [PATCH] 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. --- src/ua-parser.js | 3 +++ test/os-test.json | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/ua-parser.js b/src/ua-parser.js index 989077151..e6a7114a0 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -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], [ diff --git a/test/os-test.json b/test/os-test.json index ab973c0f5..1b05ddca6 100644 --- a/test/os-test.json +++ b/test/os-test.json @@ -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" : "",