Skip to content

Commit d414045

Browse files
committed
Backport - Fix #519 #521 #616 - Improve iPhone & iOS detection
(cherry picked from commit a1d816a)
1 parent ba067bd commit d414045

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Diff for: src/ua-parser.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@
390390
], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [
391391

392392
// Apple
393-
/\((ip(?:hone|od)[\w ]*);/i // iPod/iPhone
393+
/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i // iPod/iPhone
394394
], [MODEL, [VENDOR, APPLE], [TYPE, MOBILE]], [
395395
/\((ipad);[-\w\),; ]+apple/i, // iPad
396396
/applecoremedia\/[\w\.]+ \((ipad)/i,
@@ -717,6 +717,7 @@
717717

718718
// iOS/macOS
719719
/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS
720+
/ios;fbsv\/([\d\.]+)/i,
720721
/cfnetwork\/.+darwin/i
721722
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
722723
/(mac os x) ?([\w\. ]*)/i,

Diff for: test/device-test.json

+11
Original file line numberDiff line numberDiff line change
@@ -3136,6 +3136,17 @@
31363136
"desc": "FaceBook Mobile App",
31373137
"ua": "[FBAN/FBIOS;FBAV/283.0.0.44.117;FBBV/238386386;FBDV/iPhone12,1;FBMD/iPhone;FBSN/iOS;FBSV/13.6.1;FBSS/2;FBID/phone;FBLC/en_US;FBOP/5;FBRV/240127608]",
31383138
"expect": {
3139+
"vendor": "Apple",
3140+
"model": "iPhone12,1",
3141+
"type": "mobile"
3142+
}
3143+
},
3144+
{
3145+
"desc": "Issue #519",
3146+
"ua": "ios/iPhone/14.2/SOME_CUSTOM_APP_VERSION",
3147+
"expect": {
3148+
"vendor": "Apple",
3149+
"model": "iPhone",
31393150
"type": "mobile"
31403151
}
31413152
},

Diff for: test/os-test.json

+9
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,15 @@
764764
"version" : "undefined"
765765
}
766766
},
767+
{
768+
"desc": "iOS with FaceBook Mobile App",
769+
"ua": "[FBAN/FBIOS;FBAV/283.0.0.44.117;FBBV/238386386;FBDV/iPhone12,1;FBMD/iPhone;FBSN/iOS;FBSV/13.6.1;FBSS/2;FBID/phone;FBLC/en_US;FBOP/5;FBRV/240127608]",
770+
"expect":
771+
{
772+
"name" : "iOS",
773+
"version" : "13.6.1"
774+
}
775+
},
767776
{
768777
"desc" : "watchOS",
769778
"ua" : "server-bag [Watch OS,8.4,19S546,Watch3,4]",

0 commit comments

Comments
 (0)