diff --git a/src/constants.js b/src/constants.js index 9ce0c25..1acf63d 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1,12 +1,16 @@ // NOTE: this list must be up-to-date with browsers listed in // test/acceptance/useragentstrings.yml export const BROWSER_ALIASES_MAP = { + AmazonBot: 'amazonbot', 'Amazon Silk': 'amazon_silk', 'Android Browser': 'android', + BaiduSpider: 'baiduspider', Bada: 'bada', + BingCrawler: 'bingcrawler', BlackBerry: 'blackberry', Chrome: 'chrome', Chromium: 'chromium', + DuckDuckBot: 'duckduckbot', Electron: 'electron', Epiphany: 'epiphany', Firefox: 'firefox', @@ -14,8 +18,10 @@ export const BROWSER_ALIASES_MAP = { Generic: 'generic', 'Google Search': 'google_search', Googlebot: 'googlebot', + InternetArchiveCrawler: 'internetarchivecrawler', 'Internet Explorer': 'ie', 'K-Meleon': 'k_meleon', + MetaWebCrawler: 'metawebcrawler', Maxthon: 'maxthon', 'Microsoft Edge': 'edge', 'MZ Browser': 'mz', @@ -39,26 +45,35 @@ export const BROWSER_ALIASES_MAP = { Vivaldi: 'vivaldi', 'WebOS Browser': 'webos', WeChat: 'wechat', + YahooSlurp: 'yahooslurp', 'Yandex Browser': 'yandex', + YandexBot: 'yandexbot', Roku: 'roku', + PingdomBot: 'pingdombot', }; export const BROWSER_MAP = { + amazonbot: 'AmazonBot', amazon_silk: 'Amazon Silk', android: 'Android Browser', + baiduspider: 'BaiduSpider', bada: 'Bada', + bingcrawler: 'BingCrawler', blackberry: 'BlackBerry', chrome: 'Chrome', chromium: 'Chromium', + duckduckbot: 'DuckDuckBot', electron: 'Electron', epiphany: 'Epiphany', firefox: 'Firefox', focus: 'Focus', generic: 'Generic', googlebot: 'Googlebot', + internetarchivecrawler: 'InternetArchiveCrawler', google_search: 'Google Search', ie: 'Internet Explorer', k_meleon: 'K-Meleon', + metawebcrawler: 'MetaWebCrawler', maxthon: 'Maxthon', edge: 'Microsoft Edge', mz: 'MZ Browser', @@ -83,6 +98,9 @@ export const BROWSER_MAP = { webos: 'WebOS Browser', wechat: 'WeChat', yandex: 'Yandex Browser', + yahooslurp: 'YahooSlurp', + yandexbot: 'YandexBot', + pingdombot: 'PingdomBot', }; export const PLATFORMS_MAP = { diff --git a/src/parser-browsers.js b/src/parser-browsers.js index 997d724..7edf596 100644 --- a/src/parser-browsers.js +++ b/src/parser-browsers.js @@ -45,6 +45,154 @@ const browsersList = [ }, }, + /* AmazonBot */ + { + test: [/amazonbot/i], + describe(ua) { + const browser = { + name: 'AmazonBot', + }; + const version = Utils.getFirstMatch(/amazonbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua); + + if (version) { + browser.version = version; + } + + return browser; + }, + }, + + /* BingCrawler */ + { + test: [/bingbot/i], + describe(ua) { + const browser = { + name: 'BingCrawler', + }; + const version = Utils.getFirstMatch(/bingbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua); + + if (version) { + browser.version = version; + } + + return browser; + }, + }, + + /* BaiduSpider */ + { + test: [/baiduspider/i], + describe(ua) { + const browser = { + name: 'BaiduSpider', + }; + const version = Utils.getFirstMatch(/baiduspider\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua); + + if (version) { + browser.version = version; + } + + return browser; + }, + }, + + /* DuckDuckBot */ + { + test: [/duckduckbot/i], + describe(ua) { + const browser = { + name: 'DuckDuckBot', + }; + const version = Utils.getFirstMatch(/duckduckbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua); + + if (version) { + browser.version = version; + } + + return browser; + }, + }, + + /* InternetArchiveCrawler */ + { + test: [/ia_archiver/i], + describe(ua) { + const browser = { + name: 'InternetArchiveCrawler', + }; + const version = Utils.getFirstMatch(/ia_archiver\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua); + + if (version) { + browser.version = version; + } + + return browser; + }, + }, + + /* MetaWebCrawler */ + { + test: [/facebookexternalhit/i, /facebookcatalog/i], + describe(ua) { + const browser = { + name: 'MetaWebCrawler', + }; + const version = Utils.getFirstMatch(/facebookexternalhit\/(\d+(\.\d+)+)/i, ua) + || Utils.getFirstMatch(/facebookcatalog\/(\d+(\.\d+)+)/i, ua) + || Utils.getFirstMatch(commonVersionIdentifier, ua); + + if (version) { + browser.version = version; + } + + return browser; + }, + }, + + /* YahooSlurp */ + { + test: [/yahoo!?[\s/]*slurp/i], + describe() { + return { + name: 'YahooSlurp', + }; + }, + }, + + /* YandexBot */ + { + test: [/yandexbot/i, /yandexmobilebot/i], + describe(ua) { + const browser = { + name: 'YandexBot', + }; + const version = Utils.getFirstMatch(/yandex(?:bot|mobilebot)\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua); + + if (version) { + browser.version = version; + } + + return browser; + }, + }, + + /* PingdomBot */ + { + test: [/pingdom/i], + describe(ua) { + const browser = { + name: 'PingdomBot', + }; + const version = Utils.getFirstMatch(/version[_/](\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(/pingdom\.com_bot_.*?(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua); + + if (version) { + browser.version = version; + } + + return browser; + }, + }, + /* Opera < 13.0 */ { test: [/opera/i],