From b111862cce9a9ccb97a27ac353ae855664d5bd9d Mon Sep 17 00:00:00 2001 From: Will Soares Date: Sat, 9 Mar 2019 19:27:28 -0300 Subject: [PATCH] Update rules for creating browser aliases --- CONTRIBUTING.md | 7 +++---- src/constants.js | 12 ++++++------ src/parser.js | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7400adf..79b896a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,17 +19,16 @@ See the list in `test/acceptance/useragentstrings.yml` with example user agents Whenever you add support for new browsers or notice a bug / mismatch, please update the list and check if all tests are still passing. Also, make sure to keep the list of browser aliases up-to-date in `src/constants.js`. For creating aliases, keep the following guidelines in mind: - - use snake_case style for names + - use only lowercase letters for names + - replace special characters such as space and dashes by underscore - whenever possible drop the word `browser` from the original browser name - - replace dashes with underscore - - avoid capital letters - always check for possible duplicates - aliases are supposed to also be a shorter version of the original name Examples: `Opera Coast` --> `opera_coast` `UC Browser` --> `uc` -`SeaMonkey` --> `sea_monkey` +`SeaMonkey` --> `seamonkey` ## Testing diff --git a/src/constants.js b/src/constants.js index fe80944..547ba29 100644 --- a/src/constants.js +++ b/src/constants.js @@ -4,7 +4,7 @@ const BROWSER_ALIASES_MAP = { 'Amazon Silk': 'amazon_silk', 'Android Browser': 'android', Bada: 'bada', - BlackBerry: 'black_berry', + BlackBerry: 'blackberry', Chrome: 'chrome', Chromium: 'chromium', Epiphany: 'epiphany', @@ -20,19 +20,19 @@ const BROWSER_ALIASES_MAP = { 'NAVER Whale Browser': 'naver', Opera: 'opera', 'Opera Coast': 'opera_coast', - PhantomJS: 'phantom_js', + PhantomJS: 'phantomjs', Puffin: 'puffin', - QupZilla: 'qup_zilla', + QupZilla: 'qupzilla', Safari: 'safari', Sailfish: 'sailfish', - SeaMonkey: 'sea_monkey', + SeaMonkey: 'seamonkey', Sleipnir: 'sleipnir', Swing: 'swing', Tizen: 'tizen', 'UC Browser': 'uc', Vivaldi: 'vivaldi', - 'WebOS Browser': 'web_os', - WeChat: 'we_chat', + 'WebOS Browser': 'webos', + WeChat: 'wechat', 'Yandex Browser': 'yandex' }; diff --git a/src/parser.js b/src/parser.js index eca1ed3..88706a8 100644 --- a/src/parser.js +++ b/src/parser.js @@ -407,7 +407,7 @@ class Parser { const possibleNames = [defaultBrowserName.toLowerCase()]; if (loosely) { - possibleNames.push(getBrowserAlias(defaultBrowserName).toLowerCase()); + possibleNames.push(Utils.getBrowserAlias(defaultBrowserName).toLowerCase()); } return possibleNames.indexOf(browserName.toLowerCase()) !== -1;