mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Merge tag '2.2.1'
no message
This commit is contained in:
commit
16a4936f47
@ -1,5 +1,9 @@
|
|||||||
# Bowser Changelog
|
# Bowser Changelog
|
||||||
|
|
||||||
|
### 2.2.1 (April 12, 2019)
|
||||||
|
- [ADD] Add an alias for Samsung Internet
|
||||||
|
- [FIX] Fix browser name detection for browsers without an alias (#313)
|
||||||
|
|
||||||
### 2.2.0 (April 7, 2019)
|
### 2.2.0 (April 7, 2019)
|
||||||
- [ADD] Add short aliases for browser names (#295)
|
- [ADD] Add short aliases for browser names (#295)
|
||||||
- [FIX] Fix Yandex Browser version detection (#308)
|
- [FIX] Fix Yandex Browser version detection (#308)
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bowser",
|
"name": "bowser",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bowser",
|
"name": "bowser",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"description": "Lightweight browser detector",
|
"description": "Lightweight browser detector",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"browser",
|
"browser",
|
||||||
|
@ -25,6 +25,7 @@ const BROWSER_ALIASES_MAP = {
|
|||||||
QupZilla: 'qupzilla',
|
QupZilla: 'qupzilla',
|
||||||
Safari: 'safari',
|
Safari: 'safari',
|
||||||
Sailfish: 'sailfish',
|
Sailfish: 'sailfish',
|
||||||
|
'Samsung Internet for Android': 'samsung_internet',
|
||||||
SeaMonkey: 'seamonkey',
|
SeaMonkey: 'seamonkey',
|
||||||
Sleipnir: 'sleipnir',
|
Sleipnir: 'sleipnir',
|
||||||
Swing: 'swing',
|
Swing: 'swing',
|
||||||
|
@ -343,11 +343,11 @@ class Parser {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const browser = new Bowser(UA);
|
* const browser = new Bowser(UA);
|
||||||
* if (browser.check({chrome: '>118.01.1322' }))
|
* if (browser.satisfies({chrome: '>118.01.1322' }))
|
||||||
* // or with os
|
* // or with os
|
||||||
* if (browser.check({windows: { chrome: '>118.01.1322' } }))
|
* if (browser.satisfies({windows: { chrome: '>118.01.1322' } }))
|
||||||
* // or with platforms
|
* // or with platforms
|
||||||
* if (browser.check({desktop: { chrome: '>118.01.1322' } }))
|
* if (browser.satisfies({desktop: { chrome: '>118.01.1322' } }))
|
||||||
*/
|
*/
|
||||||
satisfies(checkTree) {
|
satisfies(checkTree) {
|
||||||
const platformsAndOSes = {};
|
const platformsAndOSes = {};
|
||||||
@ -402,12 +402,19 @@ class Parser {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
isBrowser(browserName, loosely = false) {
|
/**
|
||||||
|
* Check if the browser name equals the passed string
|
||||||
|
* @param browserName The string to compare with the browser name
|
||||||
|
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isBrowser(browserName, includingAlias = false) {
|
||||||
const defaultBrowserName = this.getBrowserName();
|
const defaultBrowserName = this.getBrowserName();
|
||||||
const possibleNames = [defaultBrowserName.toLowerCase()];
|
const possibleNames = [defaultBrowserName.toLowerCase()];
|
||||||
|
const alias = Utils.getBrowserAlias(defaultBrowserName);
|
||||||
|
|
||||||
if (loosely) {
|
if (includingAlias && typeof alias !== 'undefined') {
|
||||||
possibleNames.push(Utils.getBrowserAlias(defaultBrowserName).toLowerCase());
|
possibleNames.push(alias.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
|
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
|
||||||
|
@ -8,6 +8,9 @@ const parser = new Parser(UA, true);
|
|||||||
const EDGE_UA = 'Mozilla/5.0 (Linux; Android 8.0; Pixel XL Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.0 Mobile Safari/537.36 EdgA/41.1.35.1';
|
const EDGE_UA = 'Mozilla/5.0 (Linux; Android 8.0; Pixel XL Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.0 Mobile Safari/537.36 EdgA/41.1.35.1';
|
||||||
const edgeParser = new Parser(EDGE_UA, true);
|
const edgeParser = new Parser(EDGE_UA, true);
|
||||||
|
|
||||||
|
const FOCUS_UA = 'Mozilla/5.0 (Linux; Android 7.1.1) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Focus/1.2.1 Chrome/59.0.3071.125';
|
||||||
|
const focusParser = new Parser(FOCUS_UA, true);
|
||||||
|
|
||||||
test('constructor', (t) => {
|
test('constructor', (t) => {
|
||||||
t.truthy(parser instanceof Parser);
|
t.truthy(parser instanceof Parser);
|
||||||
});
|
});
|
||||||
@ -184,3 +187,8 @@ test('Parser.isBrowser should pass when loosely checking', (t) => {
|
|||||||
t.is(edgeParser.isBrowser('edge', true), true);
|
t.is(edgeParser.isBrowser('edge', true), true);
|
||||||
t.is(edgeParser.isBrowser('Edge', true), true);
|
t.is(edgeParser.isBrowser('Edge', true), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parser.isBrowser should pass for non-aliased browsers', (t) => {
|
||||||
|
t.is(focusParser.isBrowser('Focus', true), true);
|
||||||
|
t.is(focusParser.isBrowser('Focus', false), true);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user