Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Correctly parse Kindle Fire Silk UA #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
'RockMelt',
{ 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' },
'SeaMonkey',
{ 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
{ 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated|Silk\/)' },
'Sleipnir',
'SlimBrowser',
{ 'label': 'SRWare Iron', 'pattern': 'Iron' },
Expand Down Expand Up @@ -419,12 +419,12 @@
'iPod',
'iPhone',
'Kindle',
{ 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
'Nexus',
'Nook',
'PlayBook',
'PlayStation Vita',
'PlayStation',
{ 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated|Silk\/)' },
'TouchPad',
'Transformer',
{ 'label': 'Wii U', 'pattern': 'WiiU' },
Expand Down Expand Up @@ -658,12 +658,26 @@
}
// Detect Silk desktop/accelerated modes.
else if (name == 'Silk') {
if (!/\bMobi/i.test(ua)) {
os = 'Android';
description.unshift('desktop mode');
}
if (/Accelerated *= *true/i.test(ua)) {
description.unshift('accelerated');
if (/Accelerated/.test(ua)) {
// Gen 1 Kindle Fire

if (!/\bMobi/i.test(ua)) {
os = 'Android';
description.unshift('desktop mode');
}
if (/Accelerated *= *true/i.test(ua)) {
description.unshift('accelerated');
}
} else {
if (/^Mozilla\/5\.0 \(Linux; Android/.test(ua)) {
description.unshift('tablet mode');
} else if (/^Mozilla\/5\.0 \(X11;/.test(ua)) {
description.unshift('desktop mode');
} else if (/^Mozilla\/5\.0 \(Macintosh;/.test(ua)) {
description.unshift('desktop mode');
} else if (/^Mozilla\/5\.0 \(Linux; U;/.test(ua)) {
description.unshift('mobile mode');
}
}
}
// Detect PaleMoon identifying as Firefox.
Expand Down
16 changes: 13 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@
'version': '1.0.13.81'
},

'Silk 1.0.0 on Amazon Kindle Fire (Android 2.3.4)': {
'Silk 1.0.0 (mobile mode) 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',
'manufacturer': 'Amazon',
Expand All @@ -2382,12 +2382,12 @@
'version': '1.0.0'
},

'Silk 1.0.0 (desktop mode) on Amazon Kindle Fire': {
'Silk 1.0.0 (desktop mode) on Amazon Kindle Fire (OS X 10.6.3)': {
'ua': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Cloud9/1.0.0) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16',
'layout': 'WebKit',
'manufacturer': 'Amazon',
'name': 'Silk',
'os': 'Android',
'os': 'OS X 10.6.3',
'product': 'Kindle Fire',
'version': '1.0.0'
},
Expand Down Expand Up @@ -2432,6 +2432,16 @@
'version': '1.1.0'
},

'Silk 70.5.1 (tablet mode) on Amazon Kindle Fire (Android 5.1.1)': {
'ua': 'Mozilla/5.0 (Linux; Android 5.1.1; KFDOWI) AppleWebKit/537.36 (KHTML, like Gecko) Silk/70.5.1 like Chrome/70.0.3538.110 Safari/537.36',
'layout': 'Blink',
'manufacturer': 'Amazon',
'name': 'Silk',
'os': 'Android 5.1.1',
'product': 'Kindle Fire',
'version': '70.5.1'
},

'Sleipnir 2.8.4 on Windows XP': {
'ua': 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Sleipnir 2.8.4)',
'layout': 'Trident',
Expand Down