From 594b6b1399c307412ab3eeeb23dca4ac31464205 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Thu, 12 Dec 2024 14:43:19 +0700 Subject: [PATCH] Add new OS: `Ubuntu Touch` --- src/enums/ua-parser-enums.d.ts | 1 + src/enums/ua-parser-enums.js | 1 + src/main/ua-parser.js | 5 ++++- test/data/ua/os/ubuntu-touch.json | 11 +++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/data/ua/os/ubuntu-touch.json diff --git a/src/enums/ua-parser-enums.d.ts b/src/enums/ua-parser-enums.d.ts index 5c406c39..f8cca69b 100644 --- a/src/enums/ua-parser-enums.d.ts +++ b/src/enums/ua-parser-enums.d.ts @@ -351,6 +351,7 @@ export const OS: Readonly<{ SYMBIAN: "Symbian"; TIZEN: "Tizen"; UBUNTU: "Ubuntu"; + UBUNTU_TOUCH: "Ubuntu Touch", UNIX: "Unix"; VECTORLINUX: "VectorLinux"; WATCHOS: "watchOS"; diff --git a/src/enums/ua-parser-enums.js b/src/enums/ua-parser-enums.js index 08a7afc7..67a5447b 100644 --- a/src/enums/ua-parser-enums.js +++ b/src/enums/ua-parser-enums.js @@ -366,6 +366,7 @@ const OS = Object.freeze({ SYMBIAN: 'Symbian', TIZEN: 'Tizen', UBUNTU: 'Ubuntu', + UBUNTU_TOUCH: 'Ubuntu Touch', UNIX: 'Unix', VECTORLINUX: 'VectorLinux', WATCHOS: 'watchOS', diff --git a/src/main/ua-parser.js b/src/main/ua-parser.js index 0fa08b98..620c4b03 100755 --- a/src/main/ua-parser.js +++ b/src/main/ua-parser.js @@ -922,7 +922,10 @@ // Mobile OSes /droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS - ], [VERSION, NAME], [ // Android/WebOS/QNX/Bada/RIM/Maemo/MeeGo/Sailfish OS/OpenHarmony + ], [VERSION, NAME], [ + /(ubuntu) ([\w\.]+) like android/i // Ubuntu Touch + ], [[NAME, /(.+)/, '$1 Touch'], VERSION], [ + // 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 diff --git a/test/data/ua/os/ubuntu-touch.json b/test/data/ua/os/ubuntu-touch.json new file mode 100644 index 00000000..e0aea5ff --- /dev/null +++ b/test/data/ua/os/ubuntu-touch.json @@ -0,0 +1,11 @@ +[ + { + "desc" : "Ubuntu Touch", + "ua" : "Mozilla/5.0 (Linux; Ubuntu 16.04 like Android 4.4) AppleWebKit/537.36 Chromium/65.0.3325.151 Mobile Safari/537.36", + "expect" : + { + "name" : "Ubuntu Touch", + "version" : "16.04" + } + } +] \ No newline at end of file