Skip to content

Commit

Permalink
Add support for Windows CE browsers (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
karpour committed Dec 4, 2021
1 parent 1efa6c1 commit 05a876c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@ npm-debug.log
.idea
es
yarn-error.log
package-lock.json
7 changes: 7 additions & 0 deletions src/index.ts
Expand Up @@ -83,6 +83,8 @@ export type Browser =
| 'fxios'
| 'opera-mini'
| 'opera'
| 'pie'
| 'netfront'
| 'ie'
| 'bb10'
| 'android'
Expand Down Expand Up @@ -111,6 +113,7 @@ export type OperatingSystem =
| 'Windows 8.1'
| 'Windows 10'
| 'Windows ME'
| 'Windows CE'
| 'Open BSD'
| 'Sun OS'
| 'Linux'
Expand Down Expand Up @@ -151,6 +154,9 @@ const userAgentRules: UserAgentRule[] = [
['opera-mini', /Opera Mini.*Version\/([0-9\.]+)/],
['opera', /Opera\/([0-9\.]+)(?:\s|$)/],
['opera', /OPR\/([0-9\.]+)(:?\s|$)/],
['pie',/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],
['pie',/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],
['netfront',/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],
['ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],
['ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],
['ie', /MSIE\s(7\.0)/],
Expand Down Expand Up @@ -183,6 +189,7 @@ const operatingSystemRules: OperatingSystemRule[] = [
['Windows 8.1', /(Windows NT 6.3)/],
['Windows 10', /(Windows NT 10.0)/],
['Windows ME', /Windows ME/],
['Windows CE', /Windows CE|WinCE|Microsoft Pocket Internet Explorer/],
['Open BSD', /OpenBSD/],
['Sun OS', /SunOS/],
['Chrome OS', /CrOS/],
Expand Down
48 changes: 48 additions & 0 deletions test/logic.js
Expand Up @@ -486,6 +486,54 @@ test('detects extended bot info', function(t) {
t.end();
});

/** Windows CE Ozone (CE 4.2 P/PC 2003) */
test('detects PocketPC2003', function(t) {
assertAgentString(
t,
'Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)',
{
type: 'browser',
name: 'pie',
version: '4.01.0',
os: 'Windows CE',
},
);

t.end();
});

/** Windows CE Pegasus (CE 1.0x) PIE 1.1 */
test('detects PIE 1.1', function(t) {
assertAgentString(
t,
'Mozilla/1.1 (compatible; MSPIE 1.1; Windows CE)',
{
type: 'browser',
name: 'pie',
version: '1.1.0',
os: 'Windows CE',
},
);

t.end();
});


/** Windows CE Stinger SmartPhone 2003 */
test('detects NetFront', function(t) {
assertAgentString(
t,
'Mozilla/4.0 (PDA; Windows CE;1.0.0) NetFront/3.0',
{
type: 'browser',
name: 'netfront',
version: '3.0.0',
os: 'Windows CE',
},
);

t.end();
});

test('detects extended bot info', function(t) {
assertAgentString(
Expand Down

0 comments on commit 05a876c

Please sign in to comment.