Skip to content

Commit a1d816a

Browse files
committed
Fix #519 #521 #616 - Improve iPhone & iOS detection
1 parent 0097b21 commit a1d816a

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/ua-parser.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@
462462
], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [
463463

464464
// Apple
465-
/\((ip(?:hone|od)[\w ]*);/i // iPod/iPhone
465+
/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i // iPod/iPhone
466466
], [MODEL, [VENDOR, APPLE], [TYPE, MOBILE]], [
467467
/\((ipad);[-\w\),; ]+apple/i, // iPad
468468
/applecoremedia\/[\w\.]+ \((ipad)/i,
@@ -789,6 +789,7 @@
789789

790790
// iOS/macOS
791791
/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS
792+
/ios;fbsv\/([\d\.]+)/i,
792793
/cfnetwork\/.+darwin/i
793794
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
794795
/(mac os x) ?([\w\. ]*)/i,

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
},

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)