2017-05-18 19:57:18 +00:00
|
|
|
/**
|
|
|
|
* Browsers' descriptors
|
|
|
|
*
|
|
|
|
* The idea of descriptors is simple. You should know about them two simple things:
|
|
|
|
* 1. Every descriptor has a method or property called `test` and a `describe` method.
|
|
|
|
* 2. Order of descriptors is important.
|
|
|
|
*
|
|
|
|
* More details:
|
|
|
|
* 1. Method or property `test` serves as a way to detect whether the UA string
|
|
|
|
* matches some certain browser or not. The `describe` method helps to make a result
|
|
|
|
* object with params that show some browser-specific things: name, version, etc.
|
|
|
|
* 2. Order of descriptors is important because a Parser goes through them one by one
|
|
|
|
* in course. For example, if you insert Chrome's descriptor as the first one,
|
|
|
|
* more then a half of browsers will be described as Chrome, because they will pass
|
|
|
|
* the Chrome descriptor's test.
|
|
|
|
*
|
|
|
|
* Descriptor's `test` could be a property with an array of RegExps, where every RegExp
|
|
|
|
* will be applied to a UA string to test it whether it matches or not.
|
|
|
|
* If a descriptor has two or more regexps in the `test` array it tests them one by one
|
|
|
|
* with a logical sum operation. Parser stops if it has found any RegExp that matches the UA.
|
|
|
|
*
|
|
|
|
* Or `test` could be a method. In that case it gets a Parser instance and should
|
|
|
|
* return true/false to get the Parser know if this browser descriptor matches the UA or not.
|
|
|
|
*/
|
|
|
|
|
2017-04-09 14:13:00 +00:00
|
|
|
import {
|
2017-04-09 19:09:47 +00:00
|
|
|
getFirstMatch,
|
2017-12-20 21:29:06 +00:00
|
|
|
getSecondMatch,
|
2017-04-09 14:13:00 +00:00
|
|
|
} from './utils';
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-06-08 20:01:16 +00:00
|
|
|
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
|
2017-04-04 20:03:47 +00:00
|
|
|
|
|
|
|
const browsersList = [
|
2017-12-20 20:34:29 +00:00
|
|
|
/* Opera < 13.0 */
|
2017-04-04 20:03:47 +00:00
|
|
|
{
|
|
|
|
test: [/opera/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Opera',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
2017-12-20 20:34:29 +00:00
|
|
|
|
|
|
|
/* Opera > 13.0 */
|
2017-04-04 20:03:47 +00:00
|
|
|
{
|
|
|
|
test: [/opr|opios/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Opera',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(/(?:opr|opios)[\s/](\S+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/SamsungBrowser/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Samsung Internet for Android',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
2018-07-09 18:26:43 +00:00
|
|
|
{
|
|
|
|
test: [/Whale/i],
|
|
|
|
describe(ua) {
|
|
|
|
const browser = {
|
|
|
|
name: 'NAVER Whale Browser',
|
|
|
|
};
|
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i, ua);
|
|
|
|
|
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/MZBrowser/i],
|
|
|
|
describe(ua) {
|
|
|
|
const browser = {
|
|
|
|
name: 'MZ Browser',
|
|
|
|
};
|
|
|
|
const version = getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
|
|
|
|
|
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/focus/i],
|
|
|
|
describe(ua) {
|
|
|
|
const browser = {
|
|
|
|
name: 'Focus',
|
|
|
|
};
|
|
|
|
const version = getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
|
|
|
|
|
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
|
|
|
},
|
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
{
|
|
|
|
test: [/coast/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Opera Coast',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/yabrowser/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Yandex Browser',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/ucbrowser/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'UC Browser',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/mxios/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Maxthon',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:mxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/epiphany/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Epiphany',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/puffin/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Puffin',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/sleipnir/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Sleipnir',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/k-meleon/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'K-Meleon',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/msie|trident/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Internet Explorer',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
2017-12-20 20:34:29 +00:00
|
|
|
test: [/edg([ea]|ios)/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Microsoft Edge',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 20:34:29 +00:00
|
|
|
|
|
|
|
const version = getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/vivaldi/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Vivaldi',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/seamonkey/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'SeaMonkey',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
2017-08-20 15:22:28 +00:00
|
|
|
test: [/sailfish/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Sailfish',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-08-20 15:22:28 +00:00
|
|
|
|
|
|
|
const version = getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i, ua);
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/silk/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Amazon Silk',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/phantom/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'PhantomJS',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/slimerjs/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'SlimerJS',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'BlackBerry',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
2018-07-09 18:26:43 +00:00
|
|
|
test: [/(web|hpw)[o0]s/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'WebOS Browser',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2018-07-09 18:26:43 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua) || getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
|
|
|
{
|
2017-04-09 14:13:00 +00:00
|
|
|
test: [/bada/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Bada',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-09 14:13:00 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-09 14:13:00 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-09 14:13:00 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/tizen/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Tizen',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
|
2017-04-09 14:13:00 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-09 14:13:00 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-09 14:13:00 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/qupzilla/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'QupZilla',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
|
2017-04-09 14:13:00 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-09 14:13:00 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-09 14:13:00 +00:00
|
|
|
},
|
2017-08-20 15:22:28 +00:00
|
|
|
{
|
|
|
|
test: [/firefox|iceweasel|fxios/i],
|
|
|
|
describe(ua) {
|
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Firefox',
|
2017-08-20 15:22:28 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
2017-08-20 15:22:28 +00:00
|
|
|
|
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-08-20 15:22:28 +00:00
|
|
|
},
|
2017-04-09 14:13:00 +00:00
|
|
|
{
|
|
|
|
test: [/chromium/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Chromium',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
const version = getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
|
2017-04-09 14:13:00 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-09 14:13:00 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-09 14:13:00 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/chrome|crios|crmo/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Chrome',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-06-08 20:01:16 +00:00
|
|
|
const version = getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua);
|
2017-04-09 14:13:00 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-09 14:13:00 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-09 14:13:00 +00:00
|
|
|
},
|
2017-04-09 19:09:47 +00:00
|
|
|
|
|
|
|
/* Android Browser */
|
2017-04-09 14:13:00 +00:00
|
|
|
{
|
|
|
|
test(parser) {
|
2017-08-20 15:22:28 +00:00
|
|
|
const notLikeAndroid = !parser.test(/like android/i);
|
2017-04-09 19:09:47 +00:00
|
|
|
const butAndroid = parser.test(/android/i);
|
|
|
|
return notLikeAndroid && butAndroid;
|
2017-04-09 14:13:00 +00:00
|
|
|
},
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Android Browser',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-04-09 19:09:47 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
2017-04-09 19:09:47 +00:00
|
|
|
|
|
|
|
/* Safari */
|
2017-04-04 20:03:47 +00:00
|
|
|
{
|
2017-04-09 19:09:47 +00:00
|
|
|
test: [/safari|applewebkit/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Safari',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-04-09 19:09:47 +00:00
|
|
|
const version = getFirstMatch(commonVersionIdentifier, ua);
|
2017-04-04 20:03:47 +00:00
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-09 19:09:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-09 19:09:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Googlebot */
|
|
|
|
{
|
|
|
|
test: [/googlebot/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-08-17 20:33:46 +00:00
|
|
|
const browser = {
|
2017-12-20 21:29:06 +00:00
|
|
|
name: 'Googlebot',
|
2017-08-17 20:33:46 +00:00
|
|
|
};
|
2017-04-09 19:09:47 +00:00
|
|
|
const version = getFirstMatch(/googlebot\/(\d+(\.\d+))/i, ua) || getFirstMatch(commonVersionIdentifier, ua);
|
|
|
|
|
2017-08-17 20:33:46 +00:00
|
|
|
if (version) {
|
|
|
|
browser.version = version;
|
2017-04-04 20:03:47 +00:00
|
|
|
}
|
2017-08-17 20:33:46 +00:00
|
|
|
|
|
|
|
return browser;
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
},
|
2017-04-09 19:09:47 +00:00
|
|
|
|
|
|
|
/* Something else */
|
|
|
|
{
|
|
|
|
test: [/.*/i],
|
2017-05-18 19:57:18 +00:00
|
|
|
describe(ua) {
|
2017-04-09 19:09:47 +00:00
|
|
|
return {
|
|
|
|
name: getFirstMatch(/^(.*)\/(.*) /, ua),
|
2017-12-20 21:29:06 +00:00
|
|
|
version: getSecondMatch(/^(.*)\/(.*) /, ua),
|
2017-04-09 19:09:47 +00:00
|
|
|
};
|
2017-12-20 21:29:06 +00:00
|
|
|
},
|
|
|
|
},
|
2017-04-04 20:03:47 +00:00
|
|
|
];
|
|
|
|
|
2017-04-09 14:13:00 +00:00
|
|
|
export default browsersList;
|