From 56bd805dc8eed379f70c0a9fcc6e78e5e97987cf Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Mon, 23 Dec 2024 13:30:16 +0700 Subject: [PATCH] Backport - Improve detection for Nokia device & Symbian OS (cherry picked from commit 10ab810568db032035cd11822fd8ef58c74fbe18) --- src/ua-parser.js | 20 +++++++++++--------- test/os-test.json | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ua-parser.js b/src/ua-parser.js index 39e0b86..d469a49 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -490,9 +490,11 @@ ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [ // Nokia - /(?:maemo|nokia).*(n900|lumia \d+)/i, - /nokia[-_ ]?([-\w\.]*)/i - ], [[MODEL, /_/g, ' '], [VENDOR, 'Nokia'], [TYPE, MOBILE]], [ + /(nokia) (t[12][01])/i + ], [VENDOR, MODEL, [TYPE, TABLET]], [ + /(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i, + /nokia[-_ ]?(([-\w\. ]*))/i + ], [[MODEL, /_/g, ' '], [TYPE, MOBILE], [VENDOR, 'Nokia']], [ // Google /(pixel c)\b/i // Google Pixel C @@ -807,15 +809,15 @@ // Mobile OSes /droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS - ], [VERSION, NAME], [ // Android/WebOS/QNX/Bada/RIM/Maemo/MeeGo/Sailfish OS/OpenHarmony - /(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i, - /(blackberry)\w*\/([\w\.]*)/i, // Blackberry - /(tizen|kaios)[\/ ]([\w\.]+)/i, // Tizen/KaiOS - /\((series40);/i // Series 40 + ], [VERSION, NAME], [ + /(ubuntu) ([\w\.]+) like android/i // Ubuntu Touch + ], [[NAME, /(.+)/, '$1 Touch'], VERSION], [ + // Android/Blackberry/WebOS/QNX/Bada/RIM/KaiOS/Maemo/MeeGo/S40/Sailfish OS/OpenHarmony/Tizen + /(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen|webos)\w*[-\/; ]?([\d\.]*)/i ], [NAME, VERSION], [ /\(bb(10);/i // BlackBerry 10 ], [VERSION, [NAME, BLACKBERRY]], [ - /(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i // Symbian + /(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i // Symbian ], [VERSION, [NAME, 'Symbian']], [ /mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i // Firefox OS ], [VERSION, [NAME, FIREFOX+' OS']], [ diff --git a/test/os-test.json b/test/os-test.json index b341a9e..72b5080 100644 --- a/test/os-test.json +++ b/test/os-test.json @@ -320,7 +320,7 @@ "expect" : { "name" : "QNX", - "version" : "x86pc" + "version" : "undefined" } }, { @@ -374,7 +374,7 @@ "expect" : { "name" : "Symbian", - "version" : "5.2" + "version" : "3" } }, {