Skip to content

Commit

Permalink
Fix #422 Add ARMHF in CPU Arch detection
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Mar 23, 2021
1 parent c47f458 commit effd766
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ WebOS, Windows [Phone/Mobile], Zenwalk, ...

```sh
# Possible 'cpu.architecture'
68k, amd64, arm[64], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, sparc[64]
68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, sparc[64]
```

* `getResult()`
Expand Down
8 changes: 7 additions & 1 deletion src/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@
/((?:i[346]|x)86)[;\)]/i // IA32
], [[ARCHITECTURE, 'ia32']], [

/\b(aarch64|armv?8e?l?)\b/i // ARM64
], [[ARCHITECTURE, 'arm64']], [

/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i // ARMHF
], [[ARCHITECTURE, 'armhf']], [

// PocketPC mistakenly identified as PowerPC
/windows\s(ce|mobile);\sppc;/i
], [[ARCHITECTURE, 'arm']], [
Expand All @@ -367,7 +373,7 @@
/(sun4\w)[;\)]/i // SPARC
], [[ARCHITECTURE, 'sparc']], [

/((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+[;l]))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i
/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?:64|(?=v(?:[1-7]|[5-7]1)l?|;))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i
// IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
], [[ARCHITECTURE, util.lowerize]]
],
Expand Down
42 changes: 41 additions & 1 deletion test/cpu-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@
}
},
{
"desc" : "ARMv6",
"desc" : "ARM",
"ua" : "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 635) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537",
"expect" :
{
"architecture" : "arm"
}
},
{
"desc" : "ARMv61",
"ua" : "Mozilla/5.0 (X11; U; Linux armv61; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1",
"expect" :
{
Expand All @@ -49,12 +57,44 @@
},
{
"desc" : "ARMv7",
"ua" : "Mozilla/5.0 (Linux ARMv7) WebKitGTK+/3.4.9 vimprobable2",
"expect" :
{
"architecture" : "arm"
}
},
{
"desc" : "ARMv7l",
"ua" : "Mozilla/5.0 (SMART-TV; X11; Linux armv7l) AppleWebKit/537.42 (KHTML, like Gecko) Chromium/25.0.1349.2 Chrome/25.0.1349.2 Safari/537.42",
"expect" :
{
"architecture" : "arm"
}
},
{
"desc" : "ARMv7l",
"ua" : "Mozilla/5.0 (X11; CrOS armv7l 9765.85.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.123 Safari/537.36",
"expect" :
{
"architecture" : "arm"
}
},
{
"desc" : "ARMv8",
"ua" : "Mozilla/5.0 (X11; Linux armv8l; rv:45.0) Gecko/20100101 Firefox/45.0",
"expect" :
{
"architecture" : "arm64"
}
},
{
"desc" : "AARCH64",
"ua" : "Mozilla/5.0 (X11; CrOS aarch64 13310.93.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.133 Safari/537.36",
"expect" :
{
"architecture" : "arm64"
}
},
{
"desc" : "Pocket PC",
"ua" : "Opera/9.7 (Windows Mobile; PPC; Opera Mobi/35166; U; en) Presto/2.2.1",
Expand Down

0 comments on commit effd766

Please sign in to comment.