Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Huawei HarmonyOS parser #604

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions regexes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,13 @@ os_parsers:
os_v2_replacement: '$2'
os_v3_replacement: '$3'

# Huawei HarmonyOS
- regex: 'HarmonyOS\s?(\d*).?(\d*).?(\d*)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use \d+, as otherwise this might mess up the capture groups - also, are those actually optional? if not, let's enforce a format such as \d+\.\d+\.\d+

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some Harmony OS User-Agent strings may not explicitly include the version number. Here are two examples:

e.g.

  1. with version
Mozilla/5.0 (Linux; Android 12; LIO-AN00 Build/HUAWEILIO-AN00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/97.0.4692.98 Mobile Safari/537.36 T7/13.76 BDOS/1.0 (HarmonyOS 3.0.0) SP-engine/3.17.0 baiduboxapp/13.76.0.10 (Baidu; P1 12) NABar/1.0
  1. without version
Mozilla/5.0 (Linux; Android 12; HarmonyOS; CET-AL00; HMSCore 6.14.0.322) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.196 HuaweiBrowser/15.0.9.300 Mobile Safari/537.36

Copy link
Author

@KyoUK4n KyoUK4n Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this regex: (HarmonyOS)[\s;]+(\d+|)\.?(\d+|)\.?(\d+|)

os_replacement: 'Harmony'
os_v1_replacement: '$1'
os_v2_replacement: '$2'
os_v3_replacement: '$3'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os_v1 / v2 / v3 replacements are not needed, as it will take the capture groups above in order

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see


device_parsers:

#########
Expand Down
6 changes: 6 additions & 0 deletions tests/test_os.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3369,3 +3369,9 @@ test_cases:
patch:
patch_minor:

- user_agent_string: 'Mozilla/5.0 (TAS-AL00 Build/HUAWEITAS-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/97.0.4692.98 Mobile Safari/537.36 T7/13.76 BDOS/1.0 (HarmonyOS 3.0.0) SP-engine/3.17.0 baiduboxapp/13.76.0.10 (Baidu; P1 12) NABar/1.0'
family: 'Harmony'
major: '3'
minor: '0'
patch: '0'
patch_minor: