Skip to content

Commit

Permalink
Reworked and improved version detection (to solve FF51)
Browse files Browse the repository at this point in the history
  • Loading branch information
syranide committed Mar 30, 2017
1 parent 9f87416 commit 26b441e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swf-player-version",
"version": "1.1.4",
"version": "1.1.5",
"license": "MIT",
"description": "Shockwave Flash Player version utility",
"authors": ["Andreas Svensson <[email protected]>"],
Expand Down
2 changes: 1 addition & 1 deletion npm-swf-player-version/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swf-player-version",
"version": "1.1.4",
"version": "1.1.5",
"license": "MIT",
"description": "Shockwave Flash Player version utility",
"author": "Andreas Svensson <[email protected]>",
Expand Down
18 changes: 8 additions & 10 deletions npm-swf-player-version/swf-player-version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! swf-player-version v1.1.4 | @syranide | MIT license */
/*! swf-player-version v1.1.5 | @syranide | MIT license */

'use strict';

Expand All @@ -19,17 +19,15 @@ function parseVersion(description) {

function detectAvailableVersion() {
if (typeof navigator === 'object') {
if (navigator.mimeTypes) {
if (navigator.plugins && navigator.mimeTypes) {
var plugin = navigator.plugins['Shockwave Flash'];
var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];

if (mimeType) {
var plugin = mimeType.enabledPlugin;

if (plugin) {
// Expected format "Shockwave Flash #.# r#", "Shockwave Flash #.# d#"
detectedVersion = parseVersion(plugin.description);
return;
}
// FF51 mimeType.enabledPlugin does not return a valid plugin
if (plugin && mimeType && mimeType.enabledPlugin) {
// Expected format "Shockwave Flash #.# r#", "Shockwave Flash #.# d#"
detectedVersion = parseVersion(plugin.description);
return;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swf-player-version",
"version": "1.1.4",
"version": "1.1.5",
"license": "MIT",
"description": "Shockwave Flash Player version utility",
"author": "Andreas Svensson <[email protected]>",
Expand Down
22 changes: 8 additions & 14 deletions swf-player-version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! swf-player-version v1.1.4 | @syranide | MIT license */
/*! swf-player-version v1.1.5 | @syranide | MIT license */

(function(root, factory) {
if (typeof define === 'function' && define.amd) {
Expand All @@ -14,10 +14,6 @@
var detectedVersion;

function parseVersion(description) {
if (typeof description !== 'string') {
return '0.0.0';
}

var match = description.match(/\d+/g);
if (match != null) {
return match.slice(0, 3).join('.');
Expand All @@ -28,17 +24,15 @@

function detectAvailableVersion() {
if (typeof navigator === 'object') {
if (navigator.mimeTypes) {
if (navigator.plugins && navigator.mimeTypes) {
var plugin = navigator.plugins['Shockwave Flash'];
var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];

if (mimeType) {
var plugin = mimeType.enabledPlugin;

if (plugin) {
// Expected format "Shockwave Flash #.# r#", "Shockwave Flash #.# d#"
detectedVersion = parseVersion(plugin.description);
return;
}
// FF51 mimeType.enabledPlugin does not return a valid plugin
if (plugin && mimeType && mimeType.enabledPlugin) {
// Expected format "Shockwave Flash #.# r#", "Shockwave Flash #.# d#"
detectedVersion = parseVersion(plugin.description);
return;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions swf-player-version.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 26b441e

Please sign in to comment.