From e39d6a8fc03354c2e99cad9085a7ce71ad3fb531 Mon Sep 17 00:00:00 2001 From: BendingBender Date: Tue, 25 Feb 2014 01:48:35 +0100 Subject: [PATCH 1/2] added detection for tizen and a new `tizen` flag --- README.md | 4 +++- bowser.js | 29 +++++++++++++++++++---------- bowser.min.js | 2 +- src/bowser.js | 29 +++++++++++++++++++---------- src/useragents.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 731b1d6..7685442 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Flags set for detected Browsers[Engines] * WebOS native browser as `webos`[`webkit`] * Amazon Kindle browser as `silk`[`webkit`] * Bada browser as `bada`[`webkit`] + * Tizen browser as `tizen`[`webkit`] For all detected browsers the browser version is set in the `version` field. @@ -41,8 +42,9 @@ Flags set for detected mobile Operating Systems * `firefoxos` * `webos` (`touchpad`) * `bada` + * `tizen` -Android, iOS, Windows Phone, WebOS, and Bada will all report the OS version number if it is contained in the UA string in the `osversion` field. iOS is always reported as `ios` and additionally as `iphone`/`ipad`/`ipod`, whichever one matches best. If WebOS device is an HP TouchPad the flag `touchpad` is additionally set. +Android, iOS, Windows Phone, WebOS, Bada, and Tizen will all report the OS version number if it is contained in the UA string in the `osversion` field. iOS is always reported as `ios` and additionally as `iphone`/`ipad`/`ipod`, whichever one matches best. If WebOS device is an HP TouchPad the flag `touchpad` is additionally set. All detected mobile OSes are additionally flagged `mobile`, **if they are not powering a tablet device**. If a tablet device is detected, the flag `tablet` is set instead. diff --git a/bowser.js b/bowser.js index 7fb8769..8fa6c52 100644 --- a/bowser.js +++ b/bowser.js @@ -41,7 +41,8 @@ , windowsphone = /windows phone/i.test(ua) , blackberry = /(blackberry|\bbb\d+)/i.test(ua) , rimtablet = /rim\stablet/i.test(ua) - , bada = /bada\//i.test(ua) + , bada = /bada/i.test(ua) + , tizen = /tizen/i.test(ua) , webkitVersion = /version\/(\d+(\.\d+)?)/i , firefoxVersion = /(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i , mobile = /mobi/i.test(ua) @@ -145,6 +146,14 @@ }; touchpad && (o.touchpad = t) } + else if (tizen) { + o = { + name: 'Tizen' + , webkit: t + , tizen: t + , version: getVersion(ua, /(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i, 1) || getVersion(ua, webkitVersion, 1) + }; + } else if (gecko) { o = { name: 'Gecko' @@ -182,14 +191,8 @@ // OS version extraction var osVersion; - if (android) { - osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1); - if (osVersion) { - o.osversion = osVersion; - } - } else if (iphone || ipad || ipod) { - osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1); - osVersion = (osVersion || "").replace(/[_\s]/g, '.'); + if (tizen) { + osVersion = getVersion(ua, /tizen[\/\s](\d+(\.\d+)*)/i, 1); } else if (windowsphone) { osVersion = getVersion(ua, /windows phone (?:os)?\s?(\d+(\.\d+)*)/i, 1); } else if (webos) { @@ -198,6 +201,12 @@ osVersion = getVersion(ua, /rim\stablet\sos\s(\d+(\.\d+)*)/i, 1); } else if (bada) { osVersion = getVersion(ua, /bada\/(\d+(\.\d+)*)/i, 1); + } else if (iphone || ipad || ipod) { + osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1); + osVersion = (osVersion || "").replace(/[_\s]/g, '.'); + } else if (android) { + osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1); + osVersion && (o.osversion = osVersion) } if (osVersion) { o.osversion = osVersion; @@ -207,7 +216,7 @@ var osMajorVersion = (osVersion || '').split('.')[0]; if (tablet || ipad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || rimtablet || silk || touchpad) { o.tablet = t - } else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || mobile) { + } else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || tizen || mobile) { o.mobile = t } diff --git a/bowser.min.js b/bowser.min.js index edf7235..9421aeb 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -3,4 +3,4 @@ * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2014 */ -!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function n(e,t,n){var r=e.match(t);return r&&r.length>n&&r[n]||0}function r(r){var i=/(msie|trident)/i.test(r),s=/chrome|crios|crmo/i.test(r),o=/phantom/i.test(r),u=/iphone/i.test(r),a=/ipad/i.test(r),f=/ipod/i.test(r),l=/silk/i.test(r),c=/safari/i.test(r)&&!s&&!o&&!l,h=/android/i.test(r),p=/opera/i.test(r)||/opr/i.test(r),d=/(firefox|iceweasel)/i.test(r),m=/gecko\//i.test(r),g=/seamonkey\//i.test(r),y=/(?:web|hpw)os/i.test(r),b=/touchpad\//i.test(r),w=/windows phone/i.test(r),E=/(blackberry|\bbb\d+)/i.test(r),S=/rim\stablet/i.test(r),x=/bada\//i.test(r),T=/version\/(\d+(\.\d+)?)/i,N=/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i,C=/mobi/i.test(r),k=/tablet/i.test(r),L={};f&&(u=!1);if(w)L={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,T,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),L={name:"Opera",opera:e,version:t},h&&(L.android=e),s&&(L.webkit=e);else if(i)L={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){L={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(L.android=e);if(a||f||u)L[u?"iphone":a?"ipad":"ipod"]=e,L.ios=e}else o?L={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?L={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(L={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},L[u?"iphone":a?"ipad":"ipod"]=e,T.test(r)&&(L.version=n(r,T,1))):E||S?(L={name:"BlackBerry",blackberry:e},(t=n(r,T,1))?(L.version=t,L.webkit=e):L.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(L={name:"WebOS",webkit:e,webos:e,version:n(r,T,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(L.touchpad=e)):x?(L={name:"Bada",webkit:e,bada:e,version:n(r,/dolfin\/(\d+(\.\d+)?)/i,1)},b&&(L.touchpad=e)):m?(L={name:"Gecko",gecko:e,mozilla:e,version:n(r,N,1)},g?(L.name="SeaMonkey",L.seamonkey=e,L.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(L.name="Firefox",L.firefox=e),h?L.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(L.firefoxos=e)):h?L={name:"Android",webkit:e,android:e,version:n(r,T,1)}:c&&(L={name:"Safari",webkit:e,safari:e,version:n(r,T,1)});var A;h?(A=n(r,/android[ \/-](\d+(\.\d+)*)/i,1),A&&(L.osversion=A)):u||a||f?(A=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),A=(A||"").replace(/[_\s]/g,".")):w?A=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?A=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S?A=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1):x&&(A=n(r,/bada\/(\d+(\.\d+)*)/i,1)),A&&(L.osversion=A);var O=(A||"").split(".")[0];if(k||a||h&&(O==3||O==4&&!C)||S||l||b)L.tablet=e;else if(u||f||h&&C||w||E||y||x||C)L.mobile=e;return L.msie&&L.version>=9||L.chrome&&L.version>=20||L.firefox&&L.version>=10||L.safari&&L.version>=5||L.opera&&L.version>=10||L.ios&&L.osversion&&L.osversion.split(".")[0]>=6?L.a=e:L.msie&&L.version<9||L.chrome&&L.version<20||L.firefox&&L.version<10||L.safari&&L.version<5||L.opera&&L.version<10||L.ios&&L.osversion&&L.osversion.split(".")[0]<6?L.c=e:L.x=e,L}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i}) \ No newline at end of file +!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function n(e,t,n){var r=e.match(t);return r&&r.length>n&&r[n]||0}function r(r){var i=/(msie|trident)/i.test(r),s=/chrome|crios|crmo/i.test(r),o=/phantom/i.test(r),u=/iphone/i.test(r),a=/ipad/i.test(r),f=/ipod/i.test(r),l=/silk/i.test(r),c=/safari/i.test(r)&&!s&&!o&&!l,h=/android/i.test(r),p=/opera/i.test(r)||/opr/i.test(r),d=/(firefox|iceweasel)/i.test(r),m=/gecko\//i.test(r),g=/seamonkey\//i.test(r),y=/(?:web|hpw)os/i.test(r),b=/touchpad\//i.test(r),w=/windows phone/i.test(r),E=/(blackberry|\bbb\d+)/i.test(r),S=/rim\stablet/i.test(r),x=/bada/i.test(r),T=/tizen/i.test(r),N=/version\/(\d+(\.\d+)?)/i,C=/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i,k=/mobi/i.test(r),L=/tablet/i.test(r),A={};f&&(u=!1);if(w)A={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,N,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),A={name:"Opera",opera:e,version:t},h&&(A.android=e),s&&(A.webkit=e);else if(i)A={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){A={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(A.android=e);if(a||f||u)A[u?"iphone":a?"ipad":"ipod"]=e,A.ios=e}else o?A={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?A={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(A={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},A[u?"iphone":a?"ipad":"ipod"]=e,N.test(r)&&(A.version=n(r,N,1))):E||S?(A={name:"BlackBerry",blackberry:e},(t=n(r,N,1))?(A.version=t,A.webkit=e):A.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(A={name:"WebOS",webkit:e,webos:e,version:n(r,N,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(A.touchpad=e)):x?(A={name:"Bada",webkit:e,bada:e,version:n(r,/dolfin\/(\d+(\.\d+)?)/i,1)},b&&(A.touchpad=e)):T?A={name:"Tizen",webkit:e,tizen:e,version:n(r,/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i,1)||n(r,N,1)}:m?(A={name:"Gecko",gecko:e,mozilla:e,version:n(r,C,1)},g?(A.name="SeaMonkey",A.seamonkey=e,A.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(A.name="Firefox",A.firefox=e),h?A.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(A.firefoxos=e)):h?A={name:"Android",webkit:e,android:e,version:n(r,N,1)}:c&&(A={name:"Safari",webkit:e,safari:e,version:n(r,N,1)});var O;T?O=n(r,/tizen[\/\s](\d+(\.\d+)*)/i,1):w?O=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?O=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S?O=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1):x?O=n(r,/bada\/(\d+(\.\d+)*)/i,1):u||a||f?(O=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),O=(O||"").replace(/[_\s]/g,".")):h&&(O=n(r,/android[ \/-](\d+(\.\d+)*)/i,1),O&&(A.osversion=O)),O&&(A.osversion=O);var M=(O||"").split(".")[0];if(L||a||h&&(M==3||M==4&&!k)||S||l||b)A.tablet=e;else if(u||f||h&&k||w||E||y||x||T||k)A.mobile=e;return A.msie&&A.version>=9||A.chrome&&A.version>=20||A.firefox&&A.version>=10||A.safari&&A.version>=5||A.opera&&A.version>=10||A.ios&&A.osversion&&A.osversion.split(".")[0]>=6?A.a=e:A.msie&&A.version<9||A.chrome&&A.version<20||A.firefox&&A.version<10||A.safari&&A.version<5||A.opera&&A.version<10||A.ios&&A.osversion&&A.osversion.split(".")[0]<6?A.c=e:A.x=e,A}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index 32b0cf4..1ed940d 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -35,7 +35,8 @@ , windowsphone = /windows phone/i.test(ua) , blackberry = /(blackberry|\bbb\d+)/i.test(ua) , rimtablet = /rim\stablet/i.test(ua) - , bada = /bada\//i.test(ua) + , bada = /bada/i.test(ua) + , tizen = /tizen/i.test(ua) , webkitVersion = /version\/(\d+(\.\d+)?)/i , firefoxVersion = /(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i , mobile = /mobi/i.test(ua) @@ -139,6 +140,14 @@ }; touchpad && (o.touchpad = t) } + else if (tizen) { + o = { + name: 'Tizen' + , webkit: t + , tizen: t + , version: getVersion(ua, /(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i, 1) || getVersion(ua, webkitVersion, 1) + }; + } else if (gecko) { o = { name: 'Gecko' @@ -176,14 +185,8 @@ // OS version extraction var osVersion; - if (android) { - osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1); - if (osVersion) { - o.osversion = osVersion; - } - } else if (iphone || ipad || ipod) { - osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1); - osVersion = (osVersion || "").replace(/[_\s]/g, '.'); + if (tizen) { + osVersion = getVersion(ua, /tizen[\/\s](\d+(\.\d+)*)/i, 1); } else if (windowsphone) { osVersion = getVersion(ua, /windows phone (?:os)?\s?(\d+(\.\d+)*)/i, 1); } else if (webos) { @@ -192,6 +195,12 @@ osVersion = getVersion(ua, /rim\stablet\sos\s(\d+(\.\d+)*)/i, 1); } else if (bada) { osVersion = getVersion(ua, /bada\/(\d+(\.\d+)*)/i, 1); + } else if (iphone || ipad || ipod) { + osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1); + osVersion = (osVersion || "").replace(/[_\s]/g, '.'); + } else if (android) { + osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1); + osVersion && (o.osversion = osVersion) } if (osVersion) { o.osversion = osVersion; @@ -201,7 +210,7 @@ var osMajorVersion = (osVersion || '').split('.')[0]; if (tablet || ipad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || rimtablet || silk || touchpad) { o.tablet = t - } else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || mobile) { + } else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || tizen || mobile) { o.mobile = t } diff --git a/src/useragents.js b/src/useragents.js index 38d9994..fe1a1e2 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -886,6 +886,48 @@ module.exports.useragents = { , x: true } } + , Tizen: { + 'Mozilla/5.0 (Linux; Tizen 2.2; sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.2 Mobile Safari/537.3': { + tizen: true + , osversion: '2.2' + , webkit: true + , version: '2.2' + , mobile: true + , x: true + } + , 'Mozilla/5.0 (Linux; Tizen 2.1; sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.1 Mobile Safari/537.3': { + tizen: true + , osversion: '2.1' + , webkit: true + , version: '2.1' + , mobile: true + , x: true + } + , 'Mozilla/5.0 (Linux; U; Tizen 2.0; en-us) AppleWebKit/537.1 (KHTML, like Gecko) Mobile TizenBrowser/2.0': { + tizen: true + , osversion: '2.0' + , webkit: true + , version: '2.0' + , mobile: true + , x: true + } + , 'Mozilla/5.0 (Linux; U; Tizen/1.0 like Android; en-us; AppleWebKit/534.46 (KHTML, like Gecko) Tizen Browser/1.0 Mobile': { + tizen: true + , osversion: '1.0' + , webkit: true + , version: '1.0' + , mobile: true + , x: true + } + , 'Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-i9500/1.0; U; Tizen/1.0 like Android; en-us) AppleWebKit/534.46 (KHTML, like Gecko) SLP Browser/1.0 Mobile': { + tizen: true + , osversion: '1.0' + , webkit: true + , version: '1.0' + , mobile: true + , x: true + } + } , PhantomJS: { 'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34': { phantom: true From c19a6672aa832a36c5a3c613706bbe973611d7c5 Mon Sep 17 00:00:00 2001 From: BendingBender Date: Tue, 25 Feb 2014 01:52:27 +0100 Subject: [PATCH 2/2] small cleanup --- bowser.js | 1 - bowser.min.js | 2 +- src/bowser.js | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/bowser.js b/bowser.js index 8fa6c52..38e3016 100644 --- a/bowser.js +++ b/bowser.js @@ -206,7 +206,6 @@ osVersion = (osVersion || "").replace(/[_\s]/g, '.'); } else if (android) { osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1); - osVersion && (o.osversion = osVersion) } if (osVersion) { o.osversion = osVersion; diff --git a/bowser.min.js b/bowser.min.js index 9421aeb..4b29d56 100644 --- a/bowser.min.js +++ b/bowser.min.js @@ -3,4 +3,4 @@ * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2014 */ -!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function n(e,t,n){var r=e.match(t);return r&&r.length>n&&r[n]||0}function r(r){var i=/(msie|trident)/i.test(r),s=/chrome|crios|crmo/i.test(r),o=/phantom/i.test(r),u=/iphone/i.test(r),a=/ipad/i.test(r),f=/ipod/i.test(r),l=/silk/i.test(r),c=/safari/i.test(r)&&!s&&!o&&!l,h=/android/i.test(r),p=/opera/i.test(r)||/opr/i.test(r),d=/(firefox|iceweasel)/i.test(r),m=/gecko\//i.test(r),g=/seamonkey\//i.test(r),y=/(?:web|hpw)os/i.test(r),b=/touchpad\//i.test(r),w=/windows phone/i.test(r),E=/(blackberry|\bbb\d+)/i.test(r),S=/rim\stablet/i.test(r),x=/bada/i.test(r),T=/tizen/i.test(r),N=/version\/(\d+(\.\d+)?)/i,C=/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i,k=/mobi/i.test(r),L=/tablet/i.test(r),A={};f&&(u=!1);if(w)A={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,N,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),A={name:"Opera",opera:e,version:t},h&&(A.android=e),s&&(A.webkit=e);else if(i)A={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){A={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(A.android=e);if(a||f||u)A[u?"iphone":a?"ipad":"ipod"]=e,A.ios=e}else o?A={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?A={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(A={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},A[u?"iphone":a?"ipad":"ipod"]=e,N.test(r)&&(A.version=n(r,N,1))):E||S?(A={name:"BlackBerry",blackberry:e},(t=n(r,N,1))?(A.version=t,A.webkit=e):A.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(A={name:"WebOS",webkit:e,webos:e,version:n(r,N,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(A.touchpad=e)):x?(A={name:"Bada",webkit:e,bada:e,version:n(r,/dolfin\/(\d+(\.\d+)?)/i,1)},b&&(A.touchpad=e)):T?A={name:"Tizen",webkit:e,tizen:e,version:n(r,/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i,1)||n(r,N,1)}:m?(A={name:"Gecko",gecko:e,mozilla:e,version:n(r,C,1)},g?(A.name="SeaMonkey",A.seamonkey=e,A.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(A.name="Firefox",A.firefox=e),h?A.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(A.firefoxos=e)):h?A={name:"Android",webkit:e,android:e,version:n(r,N,1)}:c&&(A={name:"Safari",webkit:e,safari:e,version:n(r,N,1)});var O;T?O=n(r,/tizen[\/\s](\d+(\.\d+)*)/i,1):w?O=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?O=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S?O=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1):x?O=n(r,/bada\/(\d+(\.\d+)*)/i,1):u||a||f?(O=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),O=(O||"").replace(/[_\s]/g,".")):h&&(O=n(r,/android[ \/-](\d+(\.\d+)*)/i,1),O&&(A.osversion=O)),O&&(A.osversion=O);var M=(O||"").split(".")[0];if(L||a||h&&(M==3||M==4&&!k)||S||l||b)A.tablet=e;else if(u||f||h&&k||w||E||y||x||T||k)A.mobile=e;return A.msie&&A.version>=9||A.chrome&&A.version>=20||A.firefox&&A.version>=10||A.safari&&A.version>=5||A.opera&&A.version>=10||A.ios&&A.osversion&&A.osversion.split(".")[0]>=6?A.a=e:A.msie&&A.version<9||A.chrome&&A.version<20||A.firefox&&A.version<10||A.safari&&A.version<5||A.opera&&A.version<10||A.ios&&A.osversion&&A.osversion.split(".")[0]<6?A.c=e:A.x=e,A}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i}) \ No newline at end of file +!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function n(e,t,n){var r=e.match(t);return r&&r.length>n&&r[n]||0}function r(r){var i=/(msie|trident)/i.test(r),s=/chrome|crios|crmo/i.test(r),o=/phantom/i.test(r),u=/iphone/i.test(r),a=/ipad/i.test(r),f=/ipod/i.test(r),l=/silk/i.test(r),c=/safari/i.test(r)&&!s&&!o&&!l,h=/android/i.test(r),p=/opera/i.test(r)||/opr/i.test(r),d=/(firefox|iceweasel)/i.test(r),m=/gecko\//i.test(r),g=/seamonkey\//i.test(r),y=/(?:web|hpw)os/i.test(r),b=/touchpad\//i.test(r),w=/windows phone/i.test(r),E=/(blackberry|\bbb\d+)/i.test(r),S=/rim\stablet/i.test(r),x=/bada/i.test(r),T=/tizen/i.test(r),N=/version\/(\d+(\.\d+)?)/i,C=/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i,k=/mobi/i.test(r),L=/tablet/i.test(r),A={};f&&(u=!1);if(w)A={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,N,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),A={name:"Opera",opera:e,version:t},h&&(A.android=e),s&&(A.webkit=e);else if(i)A={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){A={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(A.android=e);if(a||f||u)A[u?"iphone":a?"ipad":"ipod"]=e,A.ios=e}else o?A={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?A={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(A={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},A[u?"iphone":a?"ipad":"ipod"]=e,N.test(r)&&(A.version=n(r,N,1))):E||S?(A={name:"BlackBerry",blackberry:e},(t=n(r,N,1))?(A.version=t,A.webkit=e):A.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(A={name:"WebOS",webkit:e,webos:e,version:n(r,N,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(A.touchpad=e)):x?(A={name:"Bada",webkit:e,bada:e,version:n(r,/dolfin\/(\d+(\.\d+)?)/i,1)},b&&(A.touchpad=e)):T?A={name:"Tizen",webkit:e,tizen:e,version:n(r,/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i,1)||n(r,N,1)}:m?(A={name:"Gecko",gecko:e,mozilla:e,version:n(r,C,1)},g?(A.name="SeaMonkey",A.seamonkey=e,A.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(A.name="Firefox",A.firefox=e),h?A.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(A.firefoxos=e)):h?A={name:"Android",webkit:e,android:e,version:n(r,N,1)}:c&&(A={name:"Safari",webkit:e,safari:e,version:n(r,N,1)});var O;T?O=n(r,/tizen[\/\s](\d+(\.\d+)*)/i,1):w?O=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?O=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S?O=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1):x?O=n(r,/bada\/(\d+(\.\d+)*)/i,1):u||a||f?(O=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),O=(O||"").replace(/[_\s]/g,".")):h&&(O=n(r,/android[ \/-](\d+(\.\d+)*)/i,1)),O&&(A.osversion=O);var M=(O||"").split(".")[0];if(L||a||h&&(M==3||M==4&&!k)||S||l||b)A.tablet=e;else if(u||f||h&&k||w||E||y||x||T||k)A.mobile=e;return A.msie&&A.version>=9||A.chrome&&A.version>=20||A.firefox&&A.version>=10||A.safari&&A.version>=5||A.opera&&A.version>=10||A.ios&&A.osversion&&A.osversion.split(".")[0]>=6?A.a=e:A.msie&&A.version<9||A.chrome&&A.version<20||A.firefox&&A.version<10||A.safari&&A.version<5||A.opera&&A.version<10||A.ios&&A.osversion&&A.osversion.split(".")[0]<6?A.c=e:A.x=e,A}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i}) \ No newline at end of file diff --git a/src/bowser.js b/src/bowser.js index 1ed940d..d225fbb 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -200,7 +200,6 @@ osVersion = (osVersion || "").replace(/[_\s]/g, '.'); } else if (android) { osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1); - osVersion && (o.osversion = osVersion) } if (osVersion) { o.osversion = osVersion;