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

Add support of rendering engines

This commit is contained in:
Denis Demchenko 2017-06-08 22:34:58 +03:00
parent 0694b30fc6
commit 3cd9da66ae
2 changed files with 21 additions and 2 deletions

View File

@ -1,10 +1,10 @@
var Parser = require('./parser');
/*! /*!
* Bowser - a browser detector * Bowser - a browser detector
* https://github.com/ded/bowser * https://github.com/ded/bowser
* MIT License | (c) Dustin Diaz 2012-2015 * MIT License | (c) Dustin Diaz 2012-2015
* MIT License | (c) Denis Demchenko 2015-2017 * MIT License | (c) Denis Demchenko 2015-2017
*/ */
import Parser from './parser';
/* /*
* Ideas * Ideas

View File

@ -29,6 +29,13 @@ import {
} from './utils'; } from './utils';
const commonVersionIdentifier = /version\/(\d+(\.\d+)?)/i; const commonVersionIdentifier = /version\/(\d+(\.\d+)?)/i;
const RENDERING_ENGINES_NAMES = {
blink: 'Blink',
webkit: 'WebKit',
gecko: 'Gecko',
presto: 'Presto',
edgehtml: 'EdgeHTML'
};
const browsersList = [ const browsersList = [
{ {
@ -170,6 +177,7 @@ const browsersList = [
return { return {
name: 'Microsoft Edge', name: 'Microsoft Edge',
engine: 'EdgeHTML',
version version
} }
} }
@ -191,6 +199,7 @@ const browsersList = [
const version = getFirstMatch(/seamonkey\/(\S+)/i, ua); const version = getFirstMatch(/seamonkey\/(\S+)/i, ua);
return { return {
name: 'SeaMonkey', name: 'SeaMonkey',
engine: RENDERING_ENGINES_NAMES.gecko,
version version
} }
} }
@ -200,7 +209,9 @@ const browsersList = [
describe(ua) { describe(ua) {
const version = getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\S+)/i, ua); const version = getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\S+)/i, ua);
return { return {
name: 'Firefox' name: 'Firefox',
engine: RENDERING_ENGINES_NAMES.gecko,
version
} }
} }
}, },
@ -306,9 +317,16 @@ const browsersList = [
test: [/chrome|crios|crmo/i], test: [/chrome|crios|crmo/i],
describe(ua) { describe(ua) {
const version = getFirstMatch(/(?:chrome|crios|crmo)\/(\S+)/i, ua); const version = getFirstMatch(/(?:chrome|crios|crmo)\/(\S+)/i, ua);
let engine;
if (/(apple)?webkit\/537\.36/i.test(ua)) {
engine = RENDERING_ENGINES_NAMES.blink;
} else {
engine = RENDERING_ENGINES_NAMES.webkit;
}
return { return {
name: 'Chrome', name: 'Chrome',
engine,
version version
} }
} }
@ -339,6 +357,7 @@ const browsersList = [
return { return {
name: 'Safari', name: 'Safari',
engine: RENDERING_ENGINES_NAMES.webkit,
version version
} }
} }