From 12f3ffd7b04b7f1c9fcaddff66619e326d6793ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 9 Aug 2025 20:47:22 +0000 Subject: [PATCH] Add HarmonyOS detection support for OpenHarmony user-agents Co-authored-by: naorpeled <6171622+naorpeled@users.noreply.github.com> --- src/constants.js | 1 + src/parser-os.js | 12 ++++++++++++ test/acceptance/useragentstrings.yml | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/constants.js b/src/constants.js index 9ce0c25..b0da115 100644 --- a/src/constants.js +++ b/src/constants.js @@ -107,6 +107,7 @@ export const OS_MAP = { ChromeOS: 'Chrome OS', PlayStation4: 'PlayStation 4', Roku: 'Roku', + HarmonyOS: 'HarmonyOS', }; export const ENGINE_MAP = { diff --git a/src/parser-os.js b/src/parser-os.js index 4c516dd..abc2aac 100644 --- a/src/parser-os.js +++ b/src/parser-os.js @@ -87,6 +87,18 @@ export default [ }, }, + /* HarmonyOS */ + { + test: [/OpenHarmony/i], + describe(ua) { + const version = Utils.getFirstMatch(/OpenHarmony\s+(\d+(\.\d+)*)/i, ua); + return { + name: OS_MAP.HarmonyOS, + version, + }; + }, + }, + /* Android */ { test(parser) { diff --git a/test/acceptance/useragentstrings.yml b/test/acceptance/useragentstrings.yml index 9fedcb4..76d08fb 100644 --- a/test/acceptance/useragentstrings.yml +++ b/test/acceptance/useragentstrings.yml @@ -365,6 +365,20 @@ type: "mobile" engine: name: "Blink" + - + ua: "Mozilla/5.0 (Phone; OpenHarmony 5.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile HuaweiBrowser/5.1.5.352" + spec: + browser: + name: "Chrome" + version: "114.0.0.0" + os: + name: "HarmonyOS" + version: "5.0" + platform: + type: "mobile" + vendor: "Huawei" + engine: + name: "Blink" Google Search: - ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/83.0.268992909 Mobile/15E148 Safari/605.1"