faisalman / ua-parser-js

UAParser.js - The Essential Web Development Tool for User-Agent Detection.
https://uaparser.dev/
GNU Affero General Public License v3.0
9.14k stars 1.19k forks source link

Win11 Correct Detection (Client Hints) #698

Closed dawesi closed 4 months ago

dawesi commented 9 months ago

Library version

Describe the bug Windows 11 is detected incorrectly as brower UA shows win10

To Reproduce

Use Firefox/Edge on Win11

Expected behavior OS Major Version 11

Screenshots

Desktop (please complete the following information):

Additional context

More context here: https://developers.whatismybrowser.com/learn/browser-detection/user-agents/detect-windows-11-user-agent


Microsoft provide detection script for detecting windows version 11 and greater here:

https://learn.microsoft.com/en-us/microsoft-edge/web-platform/how-to-detect-win11#sample-code-for-detecting-windows-11

ie:

navigator.userAgentData.getHighEntropyValues(["platformVersion"])
 .then(ua => {
   if (navigator.userAgentData.platform === "Windows") {
     const majorPlatformVersion = parseInt(ua.platformVersion.split('.')[0]);
     if (majorPlatformVersion >= 13) {
       console.log("Windows 11 or later");
      }
      else if (majorPlatformVersion > 0) {
        console.log("Windows 10");
      }
      else {
        console.log("Before Windows 10");
      }
   }
   else {
     console.log("Not running on Windows");
   }
 });
ghost commented 8 months ago

it is detected correctly for me. possibly not defining the client hints correctly win11

faisalman commented 8 months ago

Can you provide a screenshot of whats being displayed in https://uaparser.js.org/ ?