mirror of
https://github.com/lancedikson/bowser
synced 2025-12-05 06:02:14 +00:00
Change browser names to lowercase to fix case-sensitivity issues
Co-authored-by: naorpeled <6171622+naorpeled@users.noreply.github.com>
This commit is contained in:
parent
87cdc11519
commit
bc0f1ea8d4
12
README.md
12
README.md
@ -16,9 +16,11 @@ Don't hesitate to support the project on Github or [OpenCollective](https://open
|
|||||||
|
|
||||||
The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers. Check it out on this page: https://bowser-js.github.io/bowser-online/.
|
The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers. Check it out on this page: https://bowser-js.github.io/bowser-online/.
|
||||||
|
|
||||||
### ⚠️ Version 2.0 breaking changes ⚠️
|
### ⚠️ Breaking changes ⚠️
|
||||||
|
|
||||||
Version 2.0 has drastically changed the API. All available methods are on the [docs page](https://bowser-js.github.io/bowser/docs/).
|
**Version 3.0 (Current)**: Browser names are now returned in lowercase (e.g., `"chrome"`, `"firefox"` instead of `"Chrome"`, `"Firefox"`). This change improves compatibility with downstream libraries that perform case-sensitive string comparisons. If you need the display name with proper casing, use `Bowser.BROWSER_MAP[alias]`.
|
||||||
|
|
||||||
|
**Version 2.0**: Version 2.0 has drastically changed the API. All available methods are on the [docs page](https://bowser-js.github.io/bowser/docs/).
|
||||||
|
|
||||||
_For legacy code, check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch and install it through `npm install bowser@1.9.4`._
|
_For legacy code, check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch and install it through `npm install bowser@1.9.4`._
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ Often we need to pick users' browser properties such as the name, the version, t
|
|||||||
const browser = Bowser.getParser(window.navigator.userAgent);
|
const browser = Bowser.getParser(window.navigator.userAgent);
|
||||||
|
|
||||||
console.log(`The current browser name is "${browser.getBrowserName()}"`);
|
console.log(`The current browser name is "${browser.getBrowserName()}"`);
|
||||||
// The current browser name is "Internet Explorer"
|
// The current browser name is "internet explorer"
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
@ -61,7 +63,7 @@ console.log(browser.getBrowser());
|
|||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
{
|
{
|
||||||
name: "Internet Explorer"
|
name: "internet explorer"
|
||||||
version: "11.0"
|
version: "11.0"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -74,7 +76,7 @@ console.log(Bowser.parse(window.navigator.userAgent));
|
|||||||
// outputs
|
// outputs
|
||||||
{
|
{
|
||||||
browser: {
|
browser: {
|
||||||
name: "Internet Explorer"
|
name: "internet explorer"
|
||||||
version: "11.0"
|
version: "11.0"
|
||||||
},
|
},
|
||||||
os: {
|
os: {
|
||||||
|
|||||||
@ -1,46 +1,46 @@
|
|||||||
// NOTE: this list must be up-to-date with browsers listed in
|
// NOTE: this list must be up-to-date with browsers listed in
|
||||||
// test/acceptance/useragentstrings.yml
|
// test/acceptance/useragentstrings.yml
|
||||||
export const BROWSER_ALIASES_MAP = {
|
export const BROWSER_ALIASES_MAP = {
|
||||||
'Amazon Silk': 'amazon_silk',
|
'amazon silk': 'amazon_silk',
|
||||||
'Android Browser': 'android',
|
'android browser': 'android',
|
||||||
Bada: 'bada',
|
bada: 'bada',
|
||||||
BlackBerry: 'blackberry',
|
blackberry: 'blackberry',
|
||||||
Chrome: 'chrome',
|
chrome: 'chrome',
|
||||||
Chromium: 'chromium',
|
chromium: 'chromium',
|
||||||
Electron: 'electron',
|
electron: 'electron',
|
||||||
Epiphany: 'epiphany',
|
epiphany: 'epiphany',
|
||||||
Firefox: 'firefox',
|
firefox: 'firefox',
|
||||||
Focus: 'focus',
|
focus: 'focus',
|
||||||
Generic: 'generic',
|
generic: 'generic',
|
||||||
'Google Search': 'google_search',
|
'google search': 'google_search',
|
||||||
Googlebot: 'googlebot',
|
googlebot: 'googlebot',
|
||||||
'Internet Explorer': 'ie',
|
'internet explorer': 'ie',
|
||||||
'K-Meleon': 'k_meleon',
|
'k-meleon': 'k_meleon',
|
||||||
Maxthon: 'maxthon',
|
maxthon: 'maxthon',
|
||||||
'Microsoft Edge': 'edge',
|
'microsoft edge': 'edge',
|
||||||
'MZ Browser': 'mz',
|
'mz browser': 'mz',
|
||||||
'NAVER Whale Browser': 'naver',
|
'naver whale browser': 'naver',
|
||||||
Opera: 'opera',
|
opera: 'opera',
|
||||||
'Opera Coast': 'opera_coast',
|
'opera coast': 'opera_coast',
|
||||||
'Pale Moon': 'pale_moon',
|
'pale moon': 'pale_moon',
|
||||||
PhantomJS: 'phantomjs',
|
phantomjs: 'phantomjs',
|
||||||
Puffin: 'puffin',
|
puffin: 'puffin',
|
||||||
QupZilla: 'qupzilla',
|
qupzilla: 'qupzilla',
|
||||||
QQ: 'qq',
|
'qq browser': 'qq',
|
||||||
QQLite: 'qqlite',
|
'qq browser lite': 'qqlite',
|
||||||
Safari: 'safari',
|
safari: 'safari',
|
||||||
Sailfish: 'sailfish',
|
sailfish: 'sailfish',
|
||||||
'Samsung Internet for Android': 'samsung_internet',
|
'samsung internet for android': 'samsung_internet',
|
||||||
SeaMonkey: 'seamonkey',
|
seamonkey: 'seamonkey',
|
||||||
Sleipnir: 'sleipnir',
|
sleipnir: 'sleipnir',
|
||||||
Swing: 'swing',
|
swing: 'swing',
|
||||||
Tizen: 'tizen',
|
tizen: 'tizen',
|
||||||
'UC Browser': 'uc',
|
'uc browser': 'uc',
|
||||||
Vivaldi: 'vivaldi',
|
vivaldi: 'vivaldi',
|
||||||
'WebOS Browser': 'webos',
|
'webos browser': 'webos',
|
||||||
WeChat: 'wechat',
|
wechat: 'wechat',
|
||||||
'Yandex Browser': 'yandex',
|
'yandex browser': 'yandex',
|
||||||
Roku: 'roku',
|
roku: 'roku',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const BROWSER_MAP = {
|
export const BROWSER_MAP = {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const browsersList = [
|
|||||||
test: [/googlebot/i],
|
test: [/googlebot/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Googlebot',
|
name: 'googlebot',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ const browsersList = [
|
|||||||
test: [/opera/i],
|
test: [/opera/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Opera',
|
name: 'opera',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ const browsersList = [
|
|||||||
test: [/opr\/|opios/i],
|
test: [/opr\/|opios/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Opera',
|
name: 'opera',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ const browsersList = [
|
|||||||
test: [/SamsungBrowser/i],
|
test: [/SamsungBrowser/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Samsung Internet for Android',
|
name: 'samsung internet for android',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ const browsersList = [
|
|||||||
test: [/Whale/i],
|
test: [/Whale/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'NAVER Whale Browser',
|
name: 'naver whale browser',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ const browsersList = [
|
|||||||
test: [/PaleMoon/i],
|
test: [/PaleMoon/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Pale Moon',
|
name: 'pale moon',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:PaleMoon)[\s/](\d+(?:\.\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:PaleMoon)[\s/](\d+(?:\.\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ const browsersList = [
|
|||||||
test: [/MZBrowser/i],
|
test: [/MZBrowser/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'MZ Browser',
|
name: 'mz browser',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ const browsersList = [
|
|||||||
test: [/focus/i],
|
test: [/focus/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Focus',
|
name: 'focus',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ const browsersList = [
|
|||||||
test: [/swing/i],
|
test: [/swing/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Swing',
|
name: 'swing',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ const browsersList = [
|
|||||||
test: [/coast/i],
|
test: [/coast/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Opera Coast',
|
name: 'opera coast',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ const browsersList = [
|
|||||||
test: [/opt\/\d+(?:.?_?\d+)+/i],
|
test: [/opt\/\d+(?:.?_?\d+)+/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Opera Touch',
|
name: 'opera touch',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ const browsersList = [
|
|||||||
test: [/yabrowser/i],
|
test: [/yabrowser/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Yandex Browser',
|
name: 'yandex browser',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ const browsersList = [
|
|||||||
test: [/ucbrowser/i],
|
test: [/ucbrowser/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'UC Browser',
|
name: 'uc browser',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ const browsersList = [
|
|||||||
test: [/Maxthon|mxios/i],
|
test: [/Maxthon|mxios/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Maxthon',
|
name: 'maxthon',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ const browsersList = [
|
|||||||
test: [/epiphany/i],
|
test: [/epiphany/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Epiphany',
|
name: 'epiphany',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ const browsersList = [
|
|||||||
test: [/puffin/i],
|
test: [/puffin/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Puffin',
|
name: 'puffin',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ const browsersList = [
|
|||||||
test: [/sleipnir/i],
|
test: [/sleipnir/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Sleipnir',
|
name: 'sleipnir',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ const browsersList = [
|
|||||||
test: [/k-meleon/i],
|
test: [/k-meleon/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'K-Meleon',
|
name: 'k-meleon',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ const browsersList = [
|
|||||||
test: [/micromessenger/i],
|
test: [/micromessenger/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'WeChat',
|
name: 'wechat',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ const browsersList = [
|
|||||||
test: [/msie|trident/i],
|
test: [/msie|trident/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Internet Explorer',
|
name: 'internet explorer',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -352,7 +352,7 @@ const browsersList = [
|
|||||||
test: [/\sedg\//i],
|
test: [/\sedg\//i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Microsoft Edge',
|
name: 'microsoft edge',
|
||||||
};
|
};
|
||||||
|
|
||||||
const version = Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
@ -368,7 +368,7 @@ const browsersList = [
|
|||||||
test: [/edg([ea]|ios)/i],
|
test: [/edg([ea]|ios)/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Microsoft Edge',
|
name: 'microsoft edge',
|
||||||
};
|
};
|
||||||
|
|
||||||
const version = Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
@ -384,7 +384,7 @@ const browsersList = [
|
|||||||
test: [/vivaldi/i],
|
test: [/vivaldi/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Vivaldi',
|
name: 'vivaldi',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ const browsersList = [
|
|||||||
test: [/seamonkey/i],
|
test: [/seamonkey/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'SeaMonkey',
|
name: 'seamonkey',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ const browsersList = [
|
|||||||
test: [/sailfish/i],
|
test: [/sailfish/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Sailfish',
|
name: 'sailfish',
|
||||||
};
|
};
|
||||||
|
|
||||||
const version = Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i, ua);
|
const version = Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i, ua);
|
||||||
@ -430,7 +430,7 @@ const browsersList = [
|
|||||||
test: [/silk/i],
|
test: [/silk/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Amazon Silk',
|
name: 'amazon silk',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ const browsersList = [
|
|||||||
test: [/phantom/i],
|
test: [/phantom/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'PhantomJS',
|
name: 'phantomjs',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ const browsersList = [
|
|||||||
test: [/slimerjs/i],
|
test: [/slimerjs/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'SlimerJS',
|
name: 'slimerjs',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ const browsersList = [
|
|||||||
test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
|
test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'BlackBerry',
|
name: 'blackberry',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ const browsersList = [
|
|||||||
test: [/(web|hpw)[o0]s/i],
|
test: [/(web|hpw)[o0]s/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'WebOS Browser',
|
name: 'webos browser',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ const browsersList = [
|
|||||||
test: [/bada/i],
|
test: [/bada/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Bada',
|
name: 'bada',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ const browsersList = [
|
|||||||
test: [/tizen/i],
|
test: [/tizen/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Tizen',
|
name: 'tizen',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -535,7 +535,7 @@ const browsersList = [
|
|||||||
test: [/qupzilla/i],
|
test: [/qupzilla/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'QupZilla',
|
name: 'qupzilla',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -550,7 +550,7 @@ const browsersList = [
|
|||||||
test: [/firefox|iceweasel|fxios/i],
|
test: [/firefox|iceweasel|fxios/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Firefox',
|
name: 'firefox',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -565,7 +565,7 @@ const browsersList = [
|
|||||||
test: [/electron/i],
|
test: [/electron/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Electron',
|
name: 'electron',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -580,7 +580,7 @@ const browsersList = [
|
|||||||
test: [/MiuiBrowser/i],
|
test: [/MiuiBrowser/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Miui',
|
name: 'miui',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -595,7 +595,7 @@ const browsersList = [
|
|||||||
test: [/chromium/i],
|
test: [/chromium/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Chromium',
|
name: 'chromium',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -610,7 +610,7 @@ const browsersList = [
|
|||||||
test: [/chrome|crios|crmo/i],
|
test: [/chrome|crios|crmo/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Chrome',
|
name: 'chrome',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ const browsersList = [
|
|||||||
test: [/GSA/i],
|
test: [/GSA/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Google Search',
|
name: 'google search',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
@ -646,7 +646,7 @@ const browsersList = [
|
|||||||
},
|
},
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Android Browser',
|
name: 'android browser',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ const browsersList = [
|
|||||||
test: [/playstation 4/i],
|
test: [/playstation 4/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'PlayStation 4',
|
name: 'playstation 4',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
@ -680,7 +680,7 @@ const browsersList = [
|
|||||||
test: [/safari|applewebkit/i],
|
test: [/safari|applewebkit/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Safari',
|
name: 'safari',
|
||||||
};
|
};
|
||||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class Parser {
|
|||||||
* @typedef ParsedResult
|
* @typedef ParsedResult
|
||||||
* @property {Object} browser
|
* @property {Object} browser
|
||||||
* @property {String|undefined} [browser.name]
|
* @property {String|undefined} [browser.name]
|
||||||
* Browser name, like `"Chrome"` or `"Internet Explorer"`
|
* Browser name in lowercase, like `"chrome"` or `"internet explorer"`
|
||||||
* @property {String|undefined} [browser.version] Browser version as a String `"12.01.45334.10"`
|
* @property {String|undefined} [browser.version] Browser version as a String `"12.01.45334.10"`
|
||||||
* @property {Object} os
|
* @property {Object} os
|
||||||
* @property {String|undefined} [os.name] OS name, like `"Windows"` or `"macOS"`
|
* @property {String|undefined} [os.name] OS name, like `"Windows"` or `"macOS"`
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -28,13 +28,13 @@ test('Parser.parseBrowser is being called when the Parser.getBrowser() is called
|
|||||||
const spy = sinon.spy(parser, 'parseBrowser');
|
const spy = sinon.spy(parser, 'parseBrowser');
|
||||||
const b = parser.getBrowser();
|
const b = parser.getBrowser();
|
||||||
t.truthy(spy.called);
|
t.truthy(spy.called);
|
||||||
t.is(b.name, 'Opera');
|
t.is(b.name, 'opera');
|
||||||
t.is(b.version, '43.0.2442.1165');
|
t.is(b.version, '43.0.2442.1165');
|
||||||
parser.parseBrowser.restore();
|
parser.parseBrowser.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Parser.getBrowserName returns a correct result', (t) => {
|
test('Parser.getBrowserName returns a correct result', (t) => {
|
||||||
t.is(parser.getBrowserName(), 'Opera');
|
t.is(parser.getBrowserName(), 'opera');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Parser.getBrowserVersion returns a correct result', (t) => {
|
test('Parser.getBrowserVersion returns a correct result', (t) => {
|
||||||
@ -220,8 +220,8 @@ test('Parser.isBrowser should pass when loosely checking', (t) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Parser.isBrowser should pass for non-aliased browsers', (t) => {
|
test('Parser.isBrowser should pass for non-aliased browsers', (t) => {
|
||||||
t.is(focusParser.isBrowser('Focus', true), true);
|
t.is(focusParser.isBrowser('focus', true), true);
|
||||||
t.is(focusParser.isBrowser('Focus', false), true);
|
t.is(focusParser.isBrowser('focus', false), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Parser.isEngine should pass', (t) => {
|
test('Parser.isEngine should pass', (t) => {
|
||||||
|
|||||||
@ -129,8 +129,8 @@ test('assign', (t) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getBrowserAlias', (t) => {
|
test('getBrowserAlias', (t) => {
|
||||||
t.is(getBrowserAlias('Microsoft Edge'), 'edge');
|
t.is(getBrowserAlias('microsoft edge'), 'edge');
|
||||||
t.is(getBrowserAlias('Unexisting Browser'), void 0);
|
t.is(getBrowserAlias('unexisting browser'), void 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getBrowserTypeByAlias', (t) => {
|
test('getBrowserTypeByAlias', (t) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user