Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Windows CE browsers #156

Merged
merged 9 commits into from Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)/],
Comment on lines +157 to +159

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing spaces here

['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