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

add support for optional ua parameter

This commit is contained in:
Alexander Lukin 2016-06-16 16:01:45 +03:00
parent c30f6d41d9
commit 134aeede53

View File

@ -497,15 +497,30 @@
* }); * });
* *
* @param {Object} minVersions map of minimal version to browser * @param {Object} minVersions map of minimal version to browser
* @param {Boolean} strictMode flag to return false if browser wasn't found in map * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
* @param {String} [ua] user agent string
* @return {Boolean} * @return {Boolean}
*/ */
function isUnsupportedBrowser(minVersions, strictMode) { function isUnsupportedBrowser(minVersions, strictMode, ua) {
if (strictMode === void 0) { strictMode = false; } var _bowser = bowser;
var version = "" + bowser.version;
// make strictMode param optional with ua param usage
if (typeof strictMode === 'string') {
ua = strictMode;
strictMode = void(0);
}
if (strictMode === void(0)) {
strictMode = false;
}
if (ua) {
_bowser = detect(ua);
}
var version = "" + _bowser.version;
for (var browser in minVersions) { for (var browser in minVersions) {
if (minVersions.hasOwnProperty(browser)) { if (minVersions.hasOwnProperty(browser)) {
if (bowser[browser]) { if (_bowser[browser]) {
// browser version and min supported version. // browser version and min supported version.
if (compareVersions([version, minVersions[browser]]) < 0) { if (compareVersions([version, minVersions[browser]]) < 0) {
return true; // unsupported return true; // unsupported
@ -513,14 +528,14 @@
} }
} }
} }
return true && !strictMode; // not found return strictMode; // not found
} }
/** /**
* Check if browser is supported * Check if browser is supported
* *
* @param {Object} minVersions map of minimal version to browser * @param {Object} minVersions map of minimal version to browser
* @param {Boolean} strictMode flag to return false if browser wasn't found in map * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
* @return {Boolean} * @return {Boolean}
*/ */
function check(minVersions, strictMode) { function check(minVersions, strictMode) {