Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit da23c6e

Browse files
committed
Fix for OSX device recognition problem.
1 parent 7007d63 commit da23c6e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ module.exports = class UserAgentParser {
185185
if ((this.userAgent.os.family === 'Android' || this.userAgent.os.family === 'Firefox OS') && !this.isTablet()) return true;
186186
if (this.userAgent.os.family === 'BlackBerry OS' && this.userAgent.device.family !== 'Blackberry Playbook') return true;
187187
if (MOBILE_OS_FAMILIES.indexOf(this.userAgent.os.family) > -1) return true;
188+
if (this.agentStr.indexOf('J2ME') > -1 || this.agentStr.indexOf('MIDP') > -1) return true;
188189
// this is here mainly to detect Google's Mobile Spider
189190
if (this.uaString.indexOf('iPhone;') > -1) return true;
190191
if (this.uaString.indexOf('Googlebot-Mobile') > -1) return true;
@@ -224,6 +225,7 @@ module.exports = class UserAgentParser {
224225
// Returns True for 'PC' devices (Windows, Mac and Linux)
225226
if (this.uaString.indexOf('Windows NT') > -1 || PC_OS_FAMILIES.indexOf(this.userAgent.os.family) > -1) return true;
226227
// Maemo has 'Linux' and 'X11' in UA, but it is not for PC
228+
if (this.userAgent.os.family === 'Mac OS X' && this.agentStr.indexOf('Silk') === -1) return true;
227229
if (this.uaString.indexOf('Maemo') > -1) return false;
228230
if (this.userAgent.os.family.indexOf('Chrome OS') > -1) return true;
229231
if (this.uaString.indexOf('Linux') && this.uaString.indexOf('X11') > -1) return true;

test/devices.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"mac_safari": {
120120
"isBot": false,
121121
"isMobile": false,
122-
"isPc": false,
122+
"isPc": true,
123123
"isTablet": false,
124124
"isTouchCapable": false,
125125
"ua_string": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",

0 commit comments

Comments
 (0)