From 0cc6063ec81cae932fd5ef60b1237f5de1aafc75 Mon Sep 17 00:00:00 2001 From: everget Date: Wed, 18 Oct 2017 22:04:52 +0300 Subject: [PATCH] Correct Microsoft Edge' detection on iOS and Android --- src/bowser.js | 8 ++++---- src/useragents.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index aff5705..f7bbca7 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -42,7 +42,7 @@ , windows = !windowsphone && /windows/i.test(ua) , mac = !iosdevice && !silk && /macintosh/i.test(ua) , linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua) - , edgeVersion = getFirstMatch(/edge\/(\d+(\.\d+)?)/i) + , edgeVersion = getSecondMatch(/edg([ea]|ios)\/(\d+(\.\d+)?)/i) , versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i) , tablet = /tablet/i.test(ua) && !/tablet pc/i.test(ua) , mobile = !tablet && /[^-]mobi/i.test(ua) @@ -157,7 +157,7 @@ , chrome: t , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i) } - } else if (/chrome.+? edge/i.test(ua)) { + } else if (/edg([ea]|ios)/i.test(ua)) { result = { name: 'Microsoft Edge' , msedge: t @@ -329,10 +329,10 @@ } // set OS flags for platforms that have multiple browsers - if (!result.windowsphone && !result.msedge && (android || result.silk)) { + if (!result.windowsphone && (android || result.silk)) { result.android = t result.osname = 'Android' - } else if (!result.windowsphone && !result.msedge && iosdevice) { + } else if (!result.windowsphone && iosdevice) { result[iosdevice] = t result.ios = t result.osname = 'iOS' diff --git a/src/useragents.js b/src/useragents.js index 8fa9091..070b9f9 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -816,6 +816,25 @@ module.exports.useragents = { , osversion: '10' , a: true } + , 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89 Safari/603.2.4 EdgiOS/41.1.35.1': { + osname: 'iOS' + , msedge: true + , version: '41.1' + , ios: true + , iphone: true + , mobile: true + , osversion: '10.3.2' + , a: true + } + , 'Mozilla/5.0 (Linux; Android 8.0; Pixel XL Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.0 Mobile Safari/537.36 EdgA/41.1.35.1': { + osname: 'Android' + , msedge: true + , version: '41.1' + , android: true + , mobile: true + , osversion: '8.0' + , a: true + } } , Firefox: { 'Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0': {