Skip to content

Commit 05a876c

Browse files
authored
Add support for Windows CE browsers (#156)
1 parent 1efa6c1 commit 05a876c

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ npm-debug.log
55
.idea
66
es
77
yarn-error.log
8+
package-lock.json

src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export type Browser =
8383
| 'fxios'
8484
| 'opera-mini'
8585
| 'opera'
86+
| 'pie'
87+
| 'netfront'
8688
| 'ie'
8789
| 'bb10'
8890
| 'android'
@@ -111,6 +113,7 @@ export type OperatingSystem =
111113
| 'Windows 8.1'
112114
| 'Windows 10'
113115
| 'Windows ME'
116+
| 'Windows CE'
114117
| 'Open BSD'
115118
| 'Sun OS'
116119
| 'Linux'
@@ -151,6 +154,9 @@ const userAgentRules: UserAgentRule[] = [
151154
['opera-mini', /Opera Mini.*Version\/([0-9\.]+)/],
152155
['opera', /Opera\/([0-9\.]+)(?:\s|$)/],
153156
['opera', /OPR\/([0-9\.]+)(:?\s|$)/],
157+
['pie',/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],
158+
['pie',/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],
159+
['netfront',/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],
154160
['ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],
155161
['ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],
156162
['ie', /MSIE\s(7\.0)/],
@@ -183,6 +189,7 @@ const operatingSystemRules: OperatingSystemRule[] = [
183189
['Windows 8.1', /(Windows NT 6.3)/],
184190
['Windows 10', /(Windows NT 10.0)/],
185191
['Windows ME', /Windows ME/],
192+
['Windows CE', /Windows CE|WinCE|Microsoft Pocket Internet Explorer/],
186193
['Open BSD', /OpenBSD/],
187194
['Sun OS', /SunOS/],
188195
['Chrome OS', /CrOS/],

test/logic.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,54 @@ test('detects extended bot info', function(t) {
486486
t.end();
487487
});
488488

489+
/** Windows CE Ozone (CE 4.2 P/PC 2003) */
490+
test('detects PocketPC2003', function(t) {
491+
assertAgentString(
492+
t,
493+
'Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)',
494+
{
495+
type: 'browser',
496+
name: 'pie',
497+
version: '4.01.0',
498+
os: 'Windows CE',
499+
},
500+
);
501+
502+
t.end();
503+
});
504+
505+
/** Windows CE Pegasus (CE 1.0x) PIE 1.1 */
506+
test('detects PIE 1.1', function(t) {
507+
assertAgentString(
508+
t,
509+
'Mozilla/1.1 (compatible; MSPIE 1.1; Windows CE)',
510+
{
511+
type: 'browser',
512+
name: 'pie',
513+
version: '1.1.0',
514+
os: 'Windows CE',
515+
},
516+
);
517+
518+
t.end();
519+
});
520+
521+
522+
/** Windows CE Stinger SmartPhone 2003 */
523+
test('detects NetFront', function(t) {
524+
assertAgentString(
525+
t,
526+
'Mozilla/4.0 (PDA; Windows CE;1.0.0) NetFront/3.0',
527+
{
528+
type: 'browser',
529+
name: 'netfront',
530+
version: '3.0.0',
531+
os: 'Windows CE',
532+
},
533+
);
534+
535+
t.end();
536+
});
489537

490538
test('detects extended bot info', function(t) {
491539
assertAgentString(

0 commit comments

Comments
 (0)