still fixing WSL
[webi-installers/.git] / _webi / ua-detect.js
index 27d772a7113a3bfb25a78b8e7fea2c045b3b0868..89c18c8919d166d71d67aca0b778d8c6b788c6d3 100644 (file)
@@ -10,10 +10,17 @@ function getOs(ua) {
     return 'android';
   } else if (/iOS|iPhone|Macintosh|Darwin|OS\s*X|macOS|mac/i.test(ua)) {
     return 'macos';
+  } else if (/Linux/i.test(ua) && !/cygwin|msysgit/i.test(ua)) {
+    // It's the year of the Linux Desktop!
+    // See also http://www.mslinux.org/
+    // 'linux' must be tested before 'Microsoft' because WSL
+    // (TODO: does this affect cygwin / msysgit?)
+    return 'linux';
   } else if (/^ms$|Microsoft|Windows|win32|win|PowerShell/i.test(ua)) {
     // 'win' must be tested after 'darwin'
     return 'windows';
   } else if (/Linux|curl|wget/i.test(ua)) {
+    // test 'linux' again, after 'win'
     return 'linux';
   } else {
     return 'error';