Skip to content

Commit 097f736

Browse files
committed
1 parent 73c2577 commit 097f736

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/ua-parser.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@
5959
VIERA = 'Viera',
6060
XIAOMI = 'Xiaomi',
6161
ZEBRA = 'Zebra',
62-
FACEBOOK = 'Facebook';
62+
FACEBOOK = 'Facebook',
63+
CHROMIUM_OS = 'Chromium OS',
64+
MAC_OS = 'Mac OS';
6365

6466
///////////
6567
// Helper
@@ -715,7 +717,7 @@
715717
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
716718
/(mac os x) ?([\w\. ]*)/i,
717719
/(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
718-
], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
720+
], [[NAME, MAC_OS], [VERSION, /_/g, '.']], [
719721

720722
// Mobile OSes
721723
/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
@@ -739,7 +741,7 @@
739741
/crkey\/([\d\.]+)/i // Google Chromecast
740742
], [VERSION, [NAME, CHROME+'cast']], [
741743
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
742-
], [[NAME, 'Chromium OS'], VERSION],[
744+
], [[NAME, CHROMIUM_OS], VERSION],[
743745

744746
// Smart TVs
745747
/panasonic;(viera)/i, // Panasonic Viera
@@ -818,6 +820,11 @@
818820
if (!_device[TYPE] && _uach && _uach.mobile) {
819821
_device[TYPE] = MOBILE;
820822
}
823+
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
824+
if (_device[MODEL] == 'Macintosh' && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
825+
_device[MODEL] = 'iPad';
826+
_device[TYPE] = TABLET;
827+
}
821828
return _device;
822829
};
823830
this.getEngine = function () {
@@ -833,7 +840,9 @@
833840
_os[VERSION] = undefined;
834841
rgxMapper.call(_os, _ua, _rgxmap.os);
835842
if (!_os[NAME] && _uach && _uach.platform != 'Unknown') {
836-
_os[NAME] = _uach.platform.replace(/chrome/i, 'Chromium').replace(/mac/i, 'Mac ');
843+
_os[NAME] = _uach.platform
844+
.replace(/chrome os/i, CHROMIUM_OS)
845+
.replace(/macos/i, MAC_OS); // backward compatibility
837846
}
838847
return _os;
839848
};

0 commit comments

Comments
 (0)