faisalman / ua-parser-js

"Unmask Your Traffic" - UAParser.js: The Essential Web Development Tool for User-Agent Detection
https://uaparser.dev/
GNU Affero General Public License v3.0
9.28k stars 1.2k forks source link

Fix for Xbox Detection #696

Closed Beat-YT closed 10 months ago

Beat-YT commented 11 months ago

Fixed Xbox Detection for Chrome-Based Edge

Prerequisites

Type of Change

Bug fix,

Description

In 2020, Microsoft changed their browser Edge to use Chromium. Xbox now uses that Chromium Edge browser. With Chromium "Xbox" is no longer included in the user agent

Before Chromium, the User-Agent looked like this:

Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17748

With Chromium the user agent from the console is:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0

However, Xbox is still present inside of the Client Hint Sec-CH-UA-Model.

Test

I tested this implementation on the demo page

Before

image image

After

image image

Impact

To sum it up, this fixes Xbox detection for ua-parser-js!

Other Info

While the old Xbox user-agent did include the version of the console (Xbox One), it is no longer included in the newer User-Agent, meaning that os.version will have to stay undefined, as it is not possible to detect it.

Reference: Old Xbox agent on the demo page