1
0
mirror of https://github.com/lancedikson/bowser synced 2026-03-02 03:40:27 +00:00

Add support for using short version for browser name in satisfies

This commit is contained in:
Will Soares
2019-02-17 22:05:40 -03:00
parent 28bff841b3
commit a307533f74
6 changed files with 106 additions and 6 deletions

View File

@@ -392,7 +392,7 @@ class Parser {
if (browsersCounter > 0) {
const browserNames = Object.keys(browsers);
const matchingDefinition = browserNames.find(name => (this.isBrowser(name)));
const matchingDefinition = browserNames.find(name => (this.isBrowser(name, true)));
if (matchingDefinition !== void 0) {
return this.compareVersion(browsers[matchingDefinition]);
@@ -402,8 +402,15 @@ class Parser {
return undefined;
}
isBrowser(browserName) {
return this.getBrowserName(true) === String(browserName).toLowerCase();
isBrowser(browserName, loosely = false) {
const defaultBrowserName = this.getBrowserName();
const possibleNames = [defaultBrowserName.toLowerCase()];
if (loosely) {
possibleNames.push(getBrowserAlias(defaultBrowserName).toLowerCase());
}
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
}
compareVersion(version) {