Skip to content

Commit

Permalink
Added support for honor separated from Huawei (#749)
Browse files Browse the repository at this point in the history
* Added support for honor separated from Huawei

* Revert "Added support for honor separated from Huawei"

This reverts commit 28bde1c.

* Added changes wrt comments

* Added another change
  • Loading branch information
Julias0 authored Nov 9, 2024
1 parent 5948060 commit be2f167
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/enums/ua-parser-enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const DeviceVendor = Object.freeze({
APPLE : 'Apple',
SAMSUNG : 'Samsung',
HUAWEI : 'Huawei',
HONOR : 'Honor',
XIAOMI : 'Xiaomi',
OPPO : 'OPPO',
VIVO : 'Vivo',
Expand Down
7 changes: 6 additions & 1 deletion src/main/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
BLACKBERRY = 'BlackBerry',
GOOGLE = 'Google',
HUAWEI = 'Huawei',
HONOR = 'Honor',
LG = 'LG',
MICROSOFT = 'Microsoft',
MOTOROLA = 'Motorola',
Expand Down Expand Up @@ -467,10 +468,14 @@
/\b(sh-?[altvz]?\d\d[a-ekm]?)/i
], [MODEL, [VENDOR, SHARP], [TYPE, MOBILE]], [

// Honor
/(?:honor)([-\w ]+)[;\)]/i
], [MODEL, [VENDOR, HONOR], [TYPE, MOBILE]], [

// Huawei
/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
], [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]], [
/(?:huawei|honor)([-\w ]+)[;\)]/i,
/(?:huawei)([-\w ]+)[;\)]/i,
/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i
], [MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]], [

Expand Down
6 changes: 3 additions & 3 deletions test/specs/device-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@
"desc": "Huawei Honor 6A",
"ua": "Mozilla/5.0 (Linux; Android 7.0; DLI-L22 Build/HONORDLI-L22; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/79.0.3945.116 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/252.0.0.22.355;]",
"expect": {
"vendor": "Huawei",
"vendor": "Honor",
"model": "DLI-L22",
"type": "mobile"
}
Expand All @@ -641,7 +641,7 @@
"desc": "Huawei Honor 7",
"ua": "Mozilla/5.0 (Linux; Android 6.0; PLK-L01 Build/HONORPLK-L01; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/79.0.3945.116 Mobile Safari/537.36",
"expect": {
"vendor": "Huawei",
"vendor": "Honor",
"model": "PLK-L01",
"type": "mobile"
}
Expand All @@ -650,7 +650,7 @@
"desc": "Huawei 10 Lite",
"ua": "Mozilla/5.0 (Linux; Android 9; HRY-LX1 Build/HONORHRY-LX1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.91 Mobile Safari/537.36",
"expect": {
"vendor": "Huawei",
"vendor": "Honor",
"model": "HRY-LX1",
"type": "mobile"
}
Expand Down

0 comments on commit be2f167

Please sign in to comment.