mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Use snake case for alias names
This commit is contained in:
parent
a307533f74
commit
064aa812fc
@ -19,10 +19,17 @@ 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 camelcase style for names
|
||||
- use snake_case style for names
|
||||
- whenever possible drop the word `browser` from the original browser name
|
||||
- remove all dashes 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`
|
||||
|
||||
## Testing
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
// NOTE: this list must be up-to-date with browsers listed in
|
||||
// test/acceptance/useragentstrings.yml
|
||||
const BROWSER_ALIASES_MAP = {
|
||||
'Amazon Silk': 'amazonSilk',
|
||||
'Amazon Silk': 'amazon_silk',
|
||||
'Android Browser': 'android',
|
||||
Bada: 'bada',
|
||||
BlackBerry: 'blackBerry',
|
||||
BlackBerry: 'black_berry',
|
||||
Chrome: 'chrome',
|
||||
Chromium: 'chromium',
|
||||
Epiphany: 'epiphany',
|
||||
@ -13,27 +13,27 @@ const BROWSER_ALIASES_MAP = {
|
||||
Generic: 'generic',
|
||||
Googlebot: 'googlebot',
|
||||
'Internet Explorer': 'ie',
|
||||
'K-Meleon': 'kMeleon',
|
||||
'K-Meleon': 'k_meleon',
|
||||
Maxthon: 'maxthon',
|
||||
'Microsoft Edge': 'edge',
|
||||
'MZ Browser': 'mz',
|
||||
'NAVER Whale Browser': 'naver',
|
||||
Opera: 'opera',
|
||||
'Opera Coast': 'operaCoast',
|
||||
PhantomJS: 'phantomJS',
|
||||
'Opera Coast': 'opera_coast',
|
||||
PhantomJS: 'phantom_js',
|
||||
Puffin: 'puffin',
|
||||
QupZilla: 'qupZilla',
|
||||
QupZilla: 'qup_zilla',
|
||||
Safari: 'safari',
|
||||
Sailfish: 'sailfish',
|
||||
SeaMonkey: 'seaMonkey',
|
||||
SeaMonkey: 'sea_monkey',
|
||||
Sleipnir: 'sleipnir',
|
||||
Swing: 'swing',
|
||||
Tizen: 'tizen',
|
||||
'UC Browser': 'uc',
|
||||
Vivaldi: 'vivaldi',
|
||||
'WebOS Browser': 'webOS',
|
||||
WeChat: 'weChat',
|
||||
'Yandex Browser': 'yandex',
|
||||
'WebOS Browser': 'web_os',
|
||||
WeChat: 'we_chat',
|
||||
'Yandex Browser': 'yandex'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
15
test/unit/constants.js
Normal file
15
test/unit/constants.js
Normal file
@ -0,0 +1,15 @@
|
||||
import test from 'ava';
|
||||
import { BROWSER_ALIASES_MAP } from '../../src/constants';
|
||||
|
||||
test('check duplicate aliases', (t) => {
|
||||
const aliasesList = Object.keys(BROWSER_ALIASES_MAP).map(value => (BROWSER_ALIASES_MAP[value]));
|
||||
let foundOnce, foundTwice;
|
||||
|
||||
const duplicates = aliasesList.filter(item => {
|
||||
foundOnce = aliasesList.indexOf(item);
|
||||
foundTwice = aliasesList.indexOf(item, foundOnce + 1);
|
||||
return +foundTwice !== -1;
|
||||
});
|
||||
|
||||
t.deepEqual(duplicates, []);
|
||||
});
|
Loading…
Reference in New Issue
Block a user