From 388315542b129fb82d58e1b6ad32c8889f9dbd62 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 9 Jul 2020 16:52:37 +0000 Subject: [PATCH] Microsoft Linux, again --- _webi/ua-detect.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/_webi/ua-detect.js b/_webi/ua-detect.js index 5455d6c..b174fd4 100644 --- a/_webi/ua-detect.js +++ b/_webi/ua-detect.js @@ -10,13 +10,11 @@ function getOs(ua) { return 'android'; } else if (/iOS|iPhone|Macintosh|Darwin|OS\s*X|macOS|mac/i.test(ua)) { return 'macos'; - } else if (/Microsoft\s*Linux/i.test(ua)) { + } else if (/^ms$|Microsoft|Windows|win32|win|PowerShell/i.test(ua)) { // It's the year of the Linux Desktop! - // WSL / WSL2 - // (checking linux twice because I'm not sure about cygwin / msysgit) + // (TODO: what about cygwin / msysgit?) // See also http://www.mslinux.org/ - return 'linux'; - } else if (/^ms$|Microsoft|Windows|win32|win|PowerShell/i.test(ua)) { + // 'linux' must be tested before 'Microsoft' because WSL // 'win' must be tested after 'darwin' return 'windows'; } else if (/Linux|curl|wget/i.test(ua)) { -- 2.25.1