Skip to content

Commit

Permalink
Merge pull request #91 from kaimallea/amazon
Browse files Browse the repository at this point in the history
feat: update amazon regexp for better matching
  • Loading branch information
kaimallea authored Aug 11, 2019
2 parents 8183a1a + 04135b1 commit e8fb4b2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions src/__tests__/amazon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,40 @@ describe('Amazon', () => {
expect(mobile.android.device).toBe(true);
});
});

describe('Amazon Fire Generic Phone User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; Android android-version; product-model Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Mobile Safari/webkit-version';
mobile = isMobile(userAgent);
});

test('should be an Amazon Phone', () => {
expect(mobile.amazon.phone).toBe(true);
});

test('should not be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).not.toBe(true);
});

test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});

test('should be an Android Phone', () => {
expect(mobile.android.phone).toBe(true);
});

test('should not be an Android Tablet', () => {
expect(mobile.android.tablet).not.toBe(true);
});

test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});

test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
});
4 changes: 2 additions & 2 deletions src/isMobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const appleIpod = /iPod/i;
const appleTablet = /iPad/i;
const androidPhone = /\bAndroid(?:.+)Mobile\b/i; // Match 'Android' AND 'Mobile'
const androidTablet = /Android/i;
const amazonPhone = /\bAndroid(?:.+)SD4930UR\b/i;
const amazonTablet = /\bAndroid(?:.+)(?:KF[A-Z]{2,4})\b/i;
const amazonPhone = /(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i; // Match 'Silk' AND 'Mobile'
const amazonTablet = /Silk/i;
const windowsPhone = /Windows Phone/i;
const windowsTablet = /\bWindows(?:.+)ARM\b/i; // Match 'Windows' AND 'ARM'
const otherBlackBerry = /BlackBerry/i;
Expand Down

0 comments on commit e8fb4b2

Please sign in to comment.