Update rules for creating browser aliases

pull/295/head
Will Soares 5 years ago
parent 064aa812fc
commit b111862cce

@ -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

@ -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'
}; };

@ -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;

Loading…
Cancel
Save