From d41404551f1a6d2ae789f2a2c26b89b3f1f71610 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Mon, 20 Mar 2023 23:36:51 +0700 Subject: [PATCH] Backport - Fix #519 #521 #616 - Improve iPhone & iOS detection (cherry picked from commit a1d816ae21e18c8debbe5f23657a0ce750290317) --- src/ua-parser.js | 3 ++- test/device-test.json | 11 +++++++++++ test/os-test.json | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ua-parser.js b/src/ua-parser.js index 6ca1d13f..85ab3fed 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -390,7 +390,7 @@ ], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [ // Apple - /\((ip(?:hone|od)[\w ]*);/i // iPod/iPhone + /(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i // iPod/iPhone ], [MODEL, [VENDOR, APPLE], [TYPE, MOBILE]], [ /\((ipad);[-\w\),; ]+apple/i, // iPad /applecoremedia\/[\w\.]+ \((ipad)/i, @@ -717,6 +717,7 @@ // iOS/macOS /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS + /ios;fbsv\/([\d\.]+)/i, /cfnetwork\/.+darwin/i ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [ /(mac os x) ?([\w\. ]*)/i, diff --git a/test/device-test.json b/test/device-test.json index d23aba1e..a7cb4b73 100644 --- a/test/device-test.json +++ b/test/device-test.json @@ -3136,6 +3136,17 @@ "desc": "FaceBook Mobile App", "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]", "expect": { + "vendor": "Apple", + "model": "iPhone12,1", + "type": "mobile" + } + }, + { + "desc": "Issue #519", + "ua": "ios/iPhone/14.2/SOME_CUSTOM_APP_VERSION", + "expect": { + "vendor": "Apple", + "model": "iPhone", "type": "mobile" } }, diff --git a/test/os-test.json b/test/os-test.json index d97c7ffc..641e6f7b 100644 --- a/test/os-test.json +++ b/test/os-test.json @@ -764,6 +764,15 @@ "version" : "undefined" } }, + { + "desc": "iOS with FaceBook Mobile App", + "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]", + "expect": + { + "name" : "iOS", + "version" : "13.6.1" + } + }, { "desc" : "watchOS", "ua" : "server-bag [Watch OS,8.4,19S546,Watch3,4]",