mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-11-30 16:48:16 +01:00
always lowercase mode and name props
This commit is contained in:
@@ -146,6 +146,10 @@ describe('getName', () => {
|
||||
expect(icon.getName('md-some-name', '', '', '')).toBe('md-some-name');
|
||||
});
|
||||
|
||||
it('always lowercase name and mode', () => {
|
||||
expect(icon.getName('SOME-NAME', 'IOS', '', '')).toBe('ios-some-name');
|
||||
});
|
||||
|
||||
it('default md name w/out mode, ios or md', () => {
|
||||
expect(icon.getName('some-name', '', '', '')).toBe('md-some-name');
|
||||
});
|
||||
|
||||
@@ -206,7 +206,7 @@ function getSvgContent(url: string) {
|
||||
|
||||
export function getName(name: string, mode: string, ios: string, md: string) {
|
||||
// default to "md" if somehow the mode wasn't set
|
||||
mode = mode || 'md';
|
||||
mode = (mode || 'md').toLowerCase();
|
||||
|
||||
// if an icon was passed in using the ios or md attributes
|
||||
// set the iconName to whatever was passed in
|
||||
@@ -219,7 +219,7 @@ export function getName(name: string, mode: string, ios: string, md: string) {
|
||||
} else if (name && !(/^md-|^ios-|^logo-/.test(name))) {
|
||||
// this does not have one of the defaults
|
||||
// so lets auto add in the mode prefix for them
|
||||
name = mode + '-' + name;
|
||||
name = mode + '-' + name.toLowerCase();
|
||||
}
|
||||
|
||||
if (typeof name !== 'string' || name.trim() === '') {
|
||||
@@ -227,7 +227,7 @@ export function getName(name: string, mode: string, ios: string, md: string) {
|
||||
}
|
||||
|
||||
// only allow alpha characters and dash
|
||||
const invalidChars = name.replace(/[a-z]|-|\d/g, '');
|
||||
const invalidChars = name.replace(/[a-z]|-|\d/gi, '');
|
||||
if (invalidChars !== '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user