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

Make versions of browsers non-required properties

This commit is contained in:
Denis Demchenko 2017-08-17 23:33:46 +03:00
parent efce17881f
commit 6976da7da5

View File

@ -34,284 +34,391 @@ const browsersList = [
{ {
test: [/opera/i], test: [/opera/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Opera'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:opera)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:opera)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Opera', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/opr|opios/i], test: [/opr|opios/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Opera'
};
const version = getFirstMatch(/(?:opr|opios)[\s\/](\S+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua); const version = getFirstMatch(/(?:opr|opios)[\s\/](\S+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
return { if (version) {
name: 'Opera', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/SamsungBrowser/i], test: [/SamsungBrowser/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Samsung Internet for Android'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Samsung Internet for Android', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/coast/i], test: [/coast/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Opera Coast'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:coast)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:coast)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Opera Coast', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/yabrowser/i], test: [/yabrowser/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Yandex Browser'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Yandex Browser', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/ucbrowser/i], test: [/ucbrowser/i],
describe(ua) { describe(ua) {
const browser = {
name: 'UC Browser'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:ucbrowser)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:ucbrowser)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'UC Browser', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/mxios/i], test: [/mxios/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Maxthon'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:mxios)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:mxios)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Maxthon', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/epiphany/i], test: [/epiphany/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Epiphany'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:epiphany)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:epiphany)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Epiphany', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/puffin/i], test: [/puffin/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Puffin'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:puffin)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:puffin)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Puffin', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/sleipnir/i], test: [/sleipnir/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Sleipnir'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:sleipnir)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:sleipnir)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Sleipnir', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/k-meleon/i], test: [/k-meleon/i],
describe(ua) { describe(ua) {
const browser = {
name: 'K-Meleon'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:k-meleon)[\s\/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:k-meleon)[\s\/](\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'K-Meleon', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/msie|trident/i], test: [/msie|trident/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Internet Explorer'
};
const version = getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Internet Explorer', browser.version = version;
version }
};
return browser;
} }
}, },
{ {
test: [/chrome.+? edge/i], test: [/chrome.+? edge/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Microsoft Edge'
};
const version = getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Microsoft Edge', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/vivaldi/i], test: [/vivaldi/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Vivaldi'
};
const version = getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Vivaldi', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/seamonkey/i], test: [/seamonkey/i],
describe(ua) { describe(ua) {
const browser = {
name: 'SeaMonkey'
};
const version = getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i, ua);
return {
name: 'SeaMonkey', if (version) {
version browser.version = version;
} }
return browser;
} }
}, },
{ {
test: [/firefox|iceweasel|fxios/i], test: [/firefox|iceweasel|fxios/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Firefox'
};
const version = getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.?_?\d+)+)/i, ua);
return {
name: 'Firefox', if (version) {
version browser.version = version;
} }
return browser;
} }
}, },
{ {
test: [/silk/i], test: [/silk/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Amazon Silk'
};
const version = getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i, ua);
return {
name: 'Amazon Silk', if (version) {
version browser.version = version;
} }
return browser;
} }
}, },
{ {
test: [/phantom/i], test: [/phantom/i],
describe(ua) { describe(ua) {
const browser = {
name: 'PhantomJS'
};
const version = getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'PhantomJS', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/slimerjs/i], test: [/slimerjs/i],
describe(ua) { describe(ua) {
const browser = {
name: 'SlimerJS'
};
const version = getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'SlimerJS', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/blackberry|\bbb\d+/i, /rim\stablet/i], test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
describe(ua) { describe(ua) {
const browser = {
name: 'BlackBerry'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'BlackBerry', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/(web|hpw)os/i], test: [/(web|hpw)os/i],
describe(ua) { describe(ua) {
const browser = {
name: 'WebOS Browser'
};
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'WebOS Browser', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/bada/i], test: [/bada/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Bada'
};
const version = getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Bada', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/tizen/i], test: [/tizen/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Tizen'
};
const version = getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua); const version = getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
return { if (version) {
name: 'Tizen', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/qupzilla/i], test: [/qupzilla/i],
describe(ua) { describe(ua) {
const browser = {
name: 'QupZilla'
};
const version = getFirstMatch(/(?:qupzilla)[\s\/](\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua); const version = getFirstMatch(/(?:qupzilla)[\s\/](\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
return { if (version) {
name: 'QupZilla', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/chromium/i], test: [/chromium/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Chromium'
};
const version = getFirstMatch(/(?:chromium)[\s\/](\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua); const version = getFirstMatch(/(?:chromium)[\s\/](\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
return { if (version) {
name: 'Chromium', browser.version = version;
version
} }
return browser;
} }
}, },
{ {
test: [/chrome|crios|crmo/i], test: [/chrome|crios|crmo/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Chrome'
};
const version = getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua); const version = getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua);
return { if (version) {
name: 'Chrome', browser.version = version;
version
} }
return browser;
} }
}, },
@ -323,12 +430,16 @@ const browsersList = [
return notLikeAndroid && butAndroid; return notLikeAndroid && butAndroid;
}, },
describe(ua) { describe(ua) {
const browser = {
name: 'Android Browser'
};
const version = getFirstMatch(commonVersionIdentifier, ua); const version = getFirstMatch(commonVersionIdentifier, ua);
return { if (version) {
name: 'Android Browser', browser.version = version;
version
} }
return browser;
} }
}, },
@ -336,12 +447,16 @@ const browsersList = [
{ {
test: [/safari|applewebkit/i], test: [/safari|applewebkit/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Safari'
};
const version = getFirstMatch(commonVersionIdentifier, ua); const version = getFirstMatch(commonVersionIdentifier, ua);
return { if (version) {
name: 'Safari', browser.version = version;
version
} }
return browser;
} }
}, },
@ -349,12 +464,16 @@ const browsersList = [
{ {
test: [/googlebot/i], test: [/googlebot/i],
describe(ua) { describe(ua) {
const browser = {
name: 'Googlebot'
};
const version = getFirstMatch(/googlebot\/(\d+(\.\d+))/i, ua) || getFirstMatch(commonVersionIdentifier, ua); const version = getFirstMatch(/googlebot\/(\d+(\.\d+))/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
return { if (version) {
name: 'Googlebot', browser.version = version;
version
} }
return browser;
} }
}, },