From 4fefc5ab047417d1b0a56d67b67aa0a865a551ee Mon Sep 17 00:00:00 2001 From: Edward Compton Date: Mon, 25 Mar 2019 02:59:16 +0000 Subject: [PATCH] Added support for Webview in iOS v12.1.4 (#96) --- src/index.ts | 1 + test/logic.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/index.ts b/src/index.ts index 34aacc9..7c50cfd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -113,6 +113,7 @@ const userAgentRules: UserAgentRule[] = [ ['facebook', /FBAV\/([0-9\.]+)/], ['instagram', /Instagram\s([0-9\.]+)/], ['ios-webview', /AppleWebKit\/([0-9\.]+).*Mobile/], + ['ios-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/], ['searchbot', SEARCHBOX_UA_REGEX], ]; const operatingSystemRules: OperatingSystemRule[] = [ diff --git a/test/logic.js b/test/logic.js index 680cff2..efb16e1 100644 --- a/test/logic.js +++ b/test/logic.js @@ -16,6 +16,11 @@ test('detects Chrome', function(t) { { name: 'chrome', version: '41.0.2228', os: 'Windows 7' } ); + assertAgentString(t, + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36', + { name: 'chrome', version: '72.0.3626', os: 'Windows 10' } + ) + t.end(); }); @@ -233,6 +238,16 @@ test('detects native iOS WebView browser', function (t) { { name: 'ios-webview', version: '605.1.15', os: 'iOS' } ); + assertAgentString(t, + 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16B92', + { name: 'ios-webview', version: '605.1.15', os: 'iOS' } + ); + + assertAgentString(t, + 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko)', + { name: 'ios-webview', version: '605.1.15', os: 'iOS' } + ); + t.end(); });