1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Fix for 'iPad' showing as the browser on iPad.

Fix for https://github.com/ded/bowser/issues/55
Added Safari as the browser name (this is expected) so that it is
consistent with the results for other devices.
Updated tests accordingly.
This commit is contained in:
lopesc 2015-11-02 22:57:28 +00:00
parent 5f933390f6
commit e6a39a02f1
3 changed files with 33 additions and 8 deletions

View File

@ -88,7 +88,8 @@
} }
else if (iosdevice) { else if (iosdevice) {
result = { result = {
name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod' name : 'Safari'
, safari: t
} }
// WTF: version is not part of user agent in web apps // WTF: version is not part of user agent in web apps
if (versionIdentifier) { if (versionIdentifier) {
@ -233,6 +234,7 @@
result.mobile = t result.mobile = t
} }
// Graded Browser Support
// Graded Browser Support // Graded Browser Support
// http://developer.yahoo.com/yui/articles/gbs // http://developer.yahoo.com/yui/articles/gbs
if (result.msedge || if (result.msedge ||
@ -250,7 +252,7 @@
else if ((result.msie && result.version < 10) || else if ((result.msie && result.version < 10) ||
(result.chrome && result.version < 20) || (result.chrome && result.version < 20) ||
(result.firefox && result.version < 20.0) || (result.firefox && result.version < 20.0) ||
(result.safari && result.version < 6) || (result.safari && result.version < 6 && !result.ios) ||
(result.opera && result.version < 10.0) || (result.opera && result.version < 10.0) ||
(result.ios && result.osversion && result.osversion.split(".")[0] < 6) (result.ios && result.osversion && result.osversion.split(".")[0] < 6)
) { ) {

View File

@ -531,6 +531,8 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, a: true , a: true
, name: 'Safari'
, safari: true
} }
, 'Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': { , 'Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': {
ios: true ios: true
@ -540,6 +542,8 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, c: true , c: true
, name: 'Safari'
, safari: true
} }
, 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3': { , 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3': {
ios: true ios: true
@ -548,6 +552,8 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
, name: 'Safari'
, safari: true
} }
, 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B5097d Safari/6531.22.7': { , 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B5097d Safari/6531.22.7': {
ios: true ios: true
@ -557,6 +563,8 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, c: true , c: true
, name: 'Safari'
, safari: true
} }
, 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_2; en-gb) AppleWebKit/526+ (KHTML, like Gecko) Version/3.1 iPhone': { , 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_2; en-gb) AppleWebKit/526+ (KHTML, like Gecko) Version/3.1 iPhone': {
ios: true ios: true
@ -565,58 +573,65 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
, name: 'Safari'
, safari: true
} }
} }
, iPad: { , iPad: {
'Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53': { 'Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53': {
ios: true ios: true
, osversion: '7.0.4' , osversion: '7.0.4'
, name: 'iPad'
, version: '7.0' , version: '7.0'
, ipad: true , ipad: true
, tablet: true , tablet: true
, webkit: true , webkit: true
, a: true , a: true
, name: 'Safari'
, safari: true
} }
, 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25': { , 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25': {
ios: true ios: true
, osversion: '6.0' , osversion: '6.0'
, name: 'iPad' , name: 'Safari'
, version: '6.0' , version: '6.0'
, ipad: true , ipad: true
, tablet: true , tablet: true
, webkit: true , webkit: true
, a: true , a: true
, safari: true
} }
, 'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3': { , 'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3': {
ios: true ios: true
, osversion: '5.1' , osversion: '5.1'
, name: 'iPad' , name: 'Safari'
, version: '5.1' , version: '5.1'
, ipad: true , ipad: true
, tablet: true , tablet: true
, webkit: true , webkit: true
, c: true , c: true
, safari: true
} }
, 'Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': { , 'Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': {
ios: true ios: true
, osversion: '4.3.2' , osversion: '4.3.2'
, name: 'iPad' , name: 'Safari'
, version: '5.0' , version: '5.0'
, ipad: true , ipad: true
, tablet: true , tablet: true
, webkit: true , webkit: true
, c: true , c: true
, safari: true
} }
, 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; es-es) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B360 Safari/531.21.10': { , 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; es-es) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B360 Safari/531.21.10': {
ios: true ios: true
, osversion: '3.2' , osversion: '3.2'
, name: 'iPad' , name: 'Safari'
, version: '4.0' , version: '4.0'
, ipad: true , ipad: true
, tablet: true , tablet: true
, webkit: true , webkit: true
, c: true , c: true
, safari: true
} }
} }
, iPod: { , iPod: {
@ -628,6 +643,8 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, a: true , a: true
, name: 'Safari'
, safari: true
} }
, 'Mozilla/5.0 (iPod; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3': { , 'Mozilla/5.0 (iPod; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3': {
ios: true ios: true
@ -637,6 +654,8 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, c: true , c: true
, name: 'Safari'
, safari: true
} }
, 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5': { , 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5': {
ios: true ios: true
@ -646,6 +665,8 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, c: true , c: true
, name: 'Safari'
, safari: true
} }
, 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3': { , 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3': {
ios: true ios: true
@ -654,6 +675,8 @@ module.exports.useragents = {
, mobile: true , mobile: true
, webkit: true , webkit: true
, x: true , x: true
, name: 'Safari'
, safari: true
} }
} }
, BlackBerry: { , BlackBerry: {

View File

@ -48,7 +48,7 @@ for (g in allUserAgents) { (function(group, userAgents) {
for (ua in userAgents) { (function(userAgent, expections) { for (ua in userAgents) { (function(userAgent, expections) {
describe('user agent "' + userAgent + '"', function() { describe('user agent "' + userAgent + '"', function() {
expections.name = group expections.name = expections.name || group
/* Get the result from bowser. */ /* Get the result from bowser. */
var result = browser._detect(userAgent) var result = browser._detect(userAgent)