Skip to content
Browse files

platform: Add support for Playstation Vita. [closes #4] [jddalton, Ni…

…elsLeenheer]
  • Loading branch information...
1 parent 97bfc9f commit a5a44166f4cb9de9d9be1d1351221e43df188523 @jdalton jdalton committed Mar 22, 2012
Showing with 38 additions and 7 deletions.
  1. +9 −7 platform.js
  2. +29 −0 test/test.js
View
16 platform.js
@@ -275,7 +275,7 @@
'Rekonq',
'RockMelt',
'SeaMonkey',
- { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk)' },
+ { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
'Sleipnir',
'SlimBrowser',
'Sunrise',
@@ -298,9 +298,10 @@
'iPod',
'iPhone',
'Kindle',
- { 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk)' },
+ { 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
'Nook',
'PlayBook',
+ 'PlayStation Vita',
'TouchPad',
'Transformer',
'Xoom'
@@ -317,7 +318,8 @@
'LG': { },
'Motorola': { 'Xoom': 1 },
'Nokia': { },
- 'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1 }
+ 'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1 },
+ 'Sony': { 'PlayStation Vita': 1 }
});
/* Detectable OSes (order is important) */
@@ -376,7 +378,7 @@
// lookup the manufacturer by product or scan the UA for the manufacturer
return result || (
value[product] ||
- value[0/*Opera 9.25 fix*/, /^[a-z]+/i.exec(product)] ||
+ value[0/*Opera 9.25 fix*/, /^[a-z]+(?: +[a-z]+)*/i.exec(product)] ||
RegExp('\\b' + (key.pattern || qualify(key)) + '(?:\\b|\\w*\\d)', 'i').exec(ua)
) && (key.label || key);
});
@@ -481,7 +483,7 @@
function getVersion(patterns) {
return reduce(patterns, function(result, pattern) {
return result || (RegExp(pattern +
- '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/-]*)', 'i').exec(ua) || 0)[1] || null;
+ '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;
});
}
@@ -523,7 +525,7 @@
os = 'Kubuntu';
}
// detect Android browsers
- else if (name == 'Chrome' && manufacturer) {
+ else if (/Chrome|Vita/.test(name + ';' + product) && manufacturer) {
name = 'Android Browser';
os = /Android/.test(os) ? os : 'Android';
}
@@ -543,7 +545,7 @@
// detect non-Opera versions (order is important)
if (!version) {
version = getVersion([
- '(?:Cloud9|Opera ?Mini|Raven|Silk)',
+ '(?:Cloud9|Opera ?Mini|Raven|Silk(?!/[\\d.]+$))',
'Version',
qualify(name),
'(?:Firefox|Minefield|NetFront)'
View
29 test/test.js
@@ -200,6 +200,15 @@
'product': 'Transformer'
},
+ 'Android Browser (like Safari 4.x) on Sony PlayStation Vita 1.00': {
+ 'ua': 'Mozilla/5.0 (PlayStation Vita 1.00) AppleWebKit/531.22.8 (KHTML, like Gecko) Silk/3.2',
+ 'layout': 'WebKit',
+ 'manufacturer': 'Sony',
+ 'name': 'Android Browser',
+ 'product': 'PlayStation Vita 1.00',
+ 'os': 'Android'
+ },
+
'Android Browser 3.0.4 (like Chrome 1.x) on Motorola Xoom (Android 3.0)': {
'ua': 'Mozilla/5.0 (Linux; U; Android 3.0; xx-xx; Xoom Build/HRI39) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2',
'layout': 'WebKit',
@@ -1445,6 +1454,26 @@
'version': '2.0.6'
},
+ 'Silk 1.0.13.81 on Amazon Kindle Fire (Android 2.3.4)': {
+ 'ua': 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Silk/1.0.13.81_10003810) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Silk-Accelerated=false',
+ 'layout': 'WebKit',
+ 'manufacturer': 'Amazon',
+ 'name': 'Silk',
+ 'os': 'Android 2.3.4',
+ 'product': 'Kindle Fire',
+ 'version': '1.0.13.81'
+ },
+
+ 'Silk 1.0.13.81 (accelerated; desktop mode) on Amazon Kindle Fire': {
+ 'ua': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; zh-cn; Silk/1.0.13.81_10003810) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true',
+ 'layout': 'WebKit',
+ 'manufacturer': 'Amazon',
+ 'name': 'Silk',
+ 'os': 'Android',
+ 'product': 'Kindle Fire',
+ 'version': '1.0.13.81'
+ },
+
'Silk 1.0.0 on Amazon Kindle Fire (Android 2.3.4)': {
'ua': 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Cloud9/1.0.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
'layout': 'WebKit',

0 comments on commit a5a4416

Please sign in to comment.
Something went wrong with that request. Please try again.