Skip to content

Commit be2f167

Browse files
authored
Added support for honor separated from Huawei (#749)
* 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
1 parent 5948060 commit be2f167

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/enums/ua-parser-enums.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const DeviceVendor = Object.freeze({
5252
APPLE : 'Apple',
5353
SAMSUNG : 'Samsung',
5454
HUAWEI : 'Huawei',
55+
HONOR : 'Honor',
5556
XIAOMI : 'Xiaomi',
5657
OPPO : 'OPPO',
5758
VIVO : 'Vivo',

src/main/ua-parser.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
BLACKBERRY = 'BlackBerry',
6969
GOOGLE = 'Google',
7070
HUAWEI = 'Huawei',
71+
HONOR = 'Honor',
7172
LG = 'LG',
7273
MICROSOFT = 'Microsoft',
7374
MOTOROLA = 'Motorola',
@@ -467,10 +468,14 @@
467468
/\b(sh-?[altvz]?\d\d[a-ekm]?)/i
468469
], [MODEL, [VENDOR, SHARP], [TYPE, MOBILE]], [
469470

471+
// Honor
472+
/(?:honor)([-\w ]+)[;\)]/i
473+
], [MODEL, [VENDOR, HONOR], [TYPE, MOBILE]], [
474+
470475
// Huawei
471476
/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
472477
], [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]], [
473-
/(?:huawei|honor)([-\w ]+)[;\)]/i,
478+
/(?:huawei)([-\w ]+)[;\)]/i,
474479
/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i
475480
], [MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]], [
476481

test/specs/device-all.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@
632632
"desc": "Huawei Honor 6A",
633633
"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;]",
634634
"expect": {
635-
"vendor": "Huawei",
635+
"vendor": "Honor",
636636
"model": "DLI-L22",
637637
"type": "mobile"
638638
}
@@ -641,7 +641,7 @@
641641
"desc": "Huawei Honor 7",
642642
"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",
643643
"expect": {
644-
"vendor": "Huawei",
644+
"vendor": "Honor",
645645
"model": "PLK-L01",
646646
"type": "mobile"
647647
}
@@ -650,7 +650,7 @@
650650
"desc": "Huawei 10 Lite",
651651
"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",
652652
"expect": {
653-
"vendor": "Huawei",
653+
"vendor": "Honor",
654654
"model": "HRY-LX1",
655655
"type": "mobile"
656656
}

0 commit comments

Comments
 (0)