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

Update rules for creating browser aliases

This commit is contained in:
Will Soares 2019-03-09 19:27:28 -03:00
parent 064aa812fc
commit b111862cce
3 changed files with 10 additions and 11 deletions

View File

@ -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`. 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: 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 - whenever possible drop the word `browser` from the original browser name
- replace dashes with underscore
- avoid capital letters
- always check for possible duplicates - always check for possible duplicates
- aliases are supposed to also be a shorter version of the original name - aliases are supposed to also be a shorter version of the original name
Examples: Examples:
`Opera Coast` --> `opera_coast` `Opera Coast` --> `opera_coast`
`UC Browser` --> `uc` `UC Browser` --> `uc`
`SeaMonkey` --> `sea_monkey` `SeaMonkey` --> `seamonkey`
## Testing ## Testing

View File

@ -4,7 +4,7 @@ const BROWSER_ALIASES_MAP = {
'Amazon Silk': 'amazon_silk', 'Amazon Silk': 'amazon_silk',
'Android Browser': 'android', 'Android Browser': 'android',
Bada: 'bada', Bada: 'bada',
BlackBerry: 'black_berry', BlackBerry: 'blackberry',
Chrome: 'chrome', Chrome: 'chrome',
Chromium: 'chromium', Chromium: 'chromium',
Epiphany: 'epiphany', Epiphany: 'epiphany',
@ -20,19 +20,19 @@ const BROWSER_ALIASES_MAP = {
'NAVER Whale Browser': 'naver', 'NAVER Whale Browser': 'naver',
Opera: 'opera', Opera: 'opera',
'Opera Coast': 'opera_coast', 'Opera Coast': 'opera_coast',
PhantomJS: 'phantom_js', PhantomJS: 'phantomjs',
Puffin: 'puffin', Puffin: 'puffin',
QupZilla: 'qup_zilla', QupZilla: 'qupzilla',
Safari: 'safari', Safari: 'safari',
Sailfish: 'sailfish', Sailfish: 'sailfish',
SeaMonkey: 'sea_monkey', 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': 'web_os', 'WebOS Browser': 'webos',
WeChat: 'we_chat', WeChat: 'wechat',
'Yandex Browser': 'yandex' 'Yandex Browser': 'yandex'
}; };

View File

@ -407,7 +407,7 @@ class Parser {
const possibleNames = [defaultBrowserName.toLowerCase()]; const possibleNames = [defaultBrowserName.toLowerCase()];
if (loosely) { if (loosely) {
possibleNames.push(getBrowserAlias(defaultBrowserName).toLowerCase()); possibleNames.push(Utils.getBrowserAlias(defaultBrowserName).toLowerCase());
} }
return possibleNames.indexOf(browserName.toLowerCase()) !== -1; return possibleNames.indexOf(browserName.toLowerCase()) !== -1;