From aeced9ffa3303491d8179e9b29e3f14be1222afd Mon Sep 17 00:00:00 2001 From: Samuli Hiltunen Date: Mon, 13 Jan 2020 13:30:27 +0100 Subject: [PATCH 1/5] fix(apple ios universal user agent): ios universal user agent tag added support for ios universal user agent tag, which is used, for example, in inappbrowsers --- src/__tests__/browser.e2e.test.ts | 1 + src/isMobile.ts | 4 ++++ types/isMobile.d.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/src/__tests__/browser.e2e.test.ts b/src/__tests__/browser.e2e.test.ts index 5cc38d0..a2e6637 100644 --- a/src/__tests__/browser.e2e.test.ts +++ b/src/__tests__/browser.e2e.test.ts @@ -28,6 +28,7 @@ describe('E2E Tests', () => { "ipod": false, "phone": false, "tablet": false, + "universal": false, }, "other": Object { "blackberry": false, diff --git a/src/isMobile.ts b/src/isMobile.ts index eb3c569..65a3a01 100644 --- a/src/isMobile.ts +++ b/src/isMobile.ts @@ -1,6 +1,7 @@ const appleIphone = /iPhone/i; const appleIpod = /iPod/i; const appleTablet = /iPad/i; +const appleUniversal = /\biOS-universal(?:.+)Mac\b/i; const androidPhone = /\bAndroid(?:.+)Mobile\b/i; // Match 'Android' AND 'Mobile' const androidTablet = /Android/i; const amazonPhone = /(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i; // Match 'Silk' AND 'Mobile' @@ -22,6 +23,7 @@ export type isMobileResult = { phone: boolean; ipod: boolean; tablet: boolean; + universal: boolean; device: boolean; }; amazon: { @@ -79,6 +81,7 @@ export default function isMobile(userAgent?: string): isMobileResult { phone: match(appleIphone) && !match(windowsPhone), ipod: match(appleIpod), tablet: !match(appleIphone) && match(appleTablet) && !match(windowsPhone), + universal: match(appleUniversal), device: (match(appleIphone) || match(appleIpod) || match(appleTablet)) && !match(windowsPhone), @@ -129,6 +132,7 @@ export default function isMobile(userAgent?: string): isMobileResult { }; result.any = + result.apple.universal || result.apple.device || result.android.device || result.windows.device || diff --git a/types/isMobile.d.ts b/types/isMobile.d.ts index 1abac7a..8595547 100644 --- a/types/isMobile.d.ts +++ b/types/isMobile.d.ts @@ -3,6 +3,7 @@ export declare type isMobileResult = { phone: boolean; ipod: boolean; tablet: boolean; + universal: boolean; device: boolean; }; amazon: { From 1d17c46282624928cebc98d8a6f4a637f328a636 Mon Sep 17 00:00:00 2001 From: samuli-hiltunen-somedia <59830007+samuli-hiltunen-somedia@users.noreply.github.com> Date: Mon, 13 Jan 2020 14:47:24 +0100 Subject: [PATCH 2/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9bb878e..3151ccf 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ In a browser, the following properties of the global `isMobile` object will eith - `isMobile.apple.phone` - `isMobile.apple.ipod` - `isMobile.apple.tablet` +- `isMobile.apple.universal` - `isMobile.apple.device` (any mobile Apple device) ### Android devices From f09810029d43c46ef80f897dd09a7831edae8800 Mon Sep 17 00:00:00 2001 From: samuli-hiltunen-somedia <59830007+samuli-hiltunen-somedia@users.noreply.github.com> Date: Mon, 13 Jan 2020 14:48:42 +0100 Subject: [PATCH 3/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3151ccf..9d81f2d 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ A real-word example: I include the minified version of the script, inline, and a