Simplest and shortest checking method: (Tablets excluded)
navigator.userAgent.match(/"ALP-"|"AMN-"|"ANA-"|"ANE-"|"ANG-"|"AQM-"|"ARS-"|"ART-"|"ATU-"|"BAC-"|"BLA-"|"BRQ-"|"CAG-"|"CAM-"|"CAN-"|"CAZ-"|"CDL-"|"CDY-"|"CLT-"|"CRO-"|"CUN-"|"DIG-"|"DRA-"|"DUA-"|"DUB-"|"DVC-"|"ELE-"|"ELS-"|"EML-"|"EVA-"|"EVR-"|"FIG-"|"FLA-"|"FRL-"|"GLK-"|"HMA-"|"HW-"|"HWI-"|"INE-"|"JAT-"|"JEF-"|"JER-"|"JKM-"|"JNY-"|"JSC-"|"LDN-"|"LIO-"|"LON-"|"LUA-"|"LYA-"|"LYO-"|"MAR-"|"MED-"|"MHA-"|"MLA-"|"MRD-"|"MYA-"|"NCE-"|"NEO-"|"NOH-"|"NOP-"|"OCE-"|"PAR-"|"PIC-"|"POT-"|"PPA-"|"PRA-"|"RNE-"|"SEA-"|"SLA-"|"SNE-"|"SPN-"|"STK-"|"TAH-"|"TAS-"|"TET-"|"TRT-"|"VCE-"|"VIE-"|"VKY-"|"VNS-"|"VOG-"|"VTR-"|"WAS-"|"WKG-"|"WLZ-"|"YAL"/i)
This method uses prefixes and dashes as fingerprint from the device id list provided in this github repo. to detect Huawei devices.
ie. Huawei P Smart 2019 device ids: "POT-LX1AF","POT-LX2J","POT-LX1RUA","POT-LX3"
list, but used POT-
for detection.
Note: We are assuming that, this prefix is unique for Huawei. If a device with a different brand with same prefix sends the device id will also be count as Huawei.
Note about "HUAWEI" string check method, checking for this string does not guarantee if the device is Huawei.
If the visitor using a third party browser like Chrome, user-agent sent does not contain this string, It is sent when the visitor comes from an in-app browser view like, Twitter or Instagram (when you click to a link in these apps, the web site opens in a web view).It is also sent with visits from some apps like Petal Search app (Huawei's official search engine app)