From a2d0fe4361c44099bc4858ac5af6cf247ea31777 Mon Sep 17 00:00:00 2001 From: Sun Zhihao Date: Mon, 18 Nov 2019 20:47:14 +0800 Subject: [PATCH] modify 360 browser judge logic --- lib/ua-device.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ua-device.js b/lib/ua-device.js index f72fe0c..2826391 100755 --- a/lib/ua-device.js +++ b/lib/ua-device.js @@ -499,10 +499,10 @@ module.exports = function (ua) { /** * 360 Browser */ - else if (match = /360.s*aphone\s*browser\s*\(version\s*([\w.]+)\)/i.exec(ua)) { + else if (match = /360.s*aphone\s*browser\s*\(version\s*([\w.]+)\)|QHBrowser\/(\d*)\s|QihooBrowser\/(\d*)\s/i.exec(ua)) { uaData.browser.name = '360 Browser'; uaData.browser.version = { - original: match[1] + original: match[1] || match[2] }; } /** @@ -582,13 +582,13 @@ module.exports = function (ua) { if (tmpMatch = ua.match(/\s+(\w+Browser)\/?([\d\.]*)/)) { uaData.browser.name = tmpMatch[1]; if (tmpMatch[2]) { - uaData.browser.version = {original: tmpMatch[2]}; + uaData.browser.version = { original: tmpMatch[2] }; } else { - uaData.browser.version = {original: match[1]}; + uaData.browser.version = { original: match[1] }; } } else { uaData.browser.name = 'Android Chrome'; - uaData.browser.version = {original: match[1]}; + uaData.browser.version = { original: match[1] }; } } @@ -599,13 +599,13 @@ module.exports = function (ua) { if (tmpMatch = ua.match(/\s+(\w+Browser)\/?([\d\.]*)/)) { uaData.browser.name = tmpMatch[1]; if (tmpMatch[2]) { - uaData.browser.version = {original: tmpMatch[2]}; + uaData.browser.version = { original: tmpMatch[2] }; } else { - uaData.browser.version = {original: match[1]}; + uaData.browser.version = { original: match[1] }; } } else { uaData.browser.name = 'Android Browser'; - uaData.browser.version = {original: match[1]}; + uaData.browser.version = { original: match[1] }; } } @@ -645,7 +645,7 @@ module.exports = function (ua) { uaData.browser.name = '微信'; var tmpVersion = (match[1]).replace(/_/g, '.'); tmpMatch = /(\d+\.\d+\.\d+\.\d+)/.exec(tmpVersion); - if(tmpMatch) { + if (tmpMatch) { tmpVersion = tmpMatch[1]; } uaData.browser.version = { @@ -700,7 +700,7 @@ module.exports = function (ua) { } if (uaData.browser.name && !uaData.browser.version) { if (match = /Version\/([\w.]+)/i.exec(ua)) { - uaData.browser.version = { + uaData.browser.version = { original: match[1] }; }