Skip to content

Commit 5ea9f0e

Browse files
committed
1 parent 03b0a5a commit 5ea9f0e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Diff for: src/ua-parser.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
SONY = 'Sony',
5959
XIAOMI = 'Xiaomi',
6060
ZEBRA = 'Zebra',
61-
FACEBOOK = 'Facebook';
61+
FACEBOOK = 'Facebook',
62+
CHROMIUM_OS = 'Chromium OS',
63+
MAC_OS = 'Mac OS';
6264

6365
///////////
6466
// Helper
@@ -721,7 +723,7 @@
721723
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
722724
/(mac os x) ?([\w\. ]*)/i,
723725
/(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
724-
], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
726+
], [[NAME, MAC_OS], [VERSION, /_/g, '.']], [
725727

726728
// Mobile OSes
727729
/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
@@ -745,7 +747,7 @@
745747
/crkey\/([\d\.]+)/i // Google Chromecast
746748
], [VERSION, [NAME, CHROME+'cast']], [
747749
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
748-
], [[NAME, 'Chromium OS'], VERSION],[
750+
], [[NAME, CHROMIUM_OS], VERSION],[
749751

750752
// Smart TVs
751753
/panasonic;(viera)/i, // Panasonic Viera
@@ -887,6 +889,11 @@
887889
if (!_device[TYPE] && _uach && _uach.mobile) {
888890
_device[TYPE] = MOBILE;
889891
}
892+
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
893+
if (_device[MODEL] == 'Macintosh' && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
894+
_device[MODEL] = 'iPad';
895+
_device[TYPE] = TABLET;
896+
}
890897
return _device;
891898
};
892899
this.getEngine = function () {
@@ -899,8 +906,8 @@
899906
rgxMapper.call(_os, _ua, _rgxmap.os);
900907
if (!_os[NAME] && _uach && _uach.platform != 'Unknown') {
901908
_os[NAME] = _uach.platform
902-
.replace(/chrome os/i, 'Chromium OS')
903-
.replace(/macos/i, 'Mac OS'); // backward compatibility
909+
.replace(/chrome os/i, CHROMIUM_OS)
910+
.replace(/macos/i, MAC_OS); // backward compatibility
904911
}
905912
return _os;
906913
};

0 commit comments

Comments
 (0)