| 106 | }; |
| 107 | |
| 108 | export const getName = ( |
| 109 | iconName: string | undefined, |
| 110 | icon: string | undefined, |
| 111 | mode: string | undefined, |
| 112 | ios: string | undefined, |
| 113 | md: string | undefined, |
| 114 | ) => { |
| 115 | // default to "md" if somehow the mode wasn't set |
| 116 | mode = (mode && toLower(mode)) === 'ios' ? 'ios' : 'md'; |
| 117 | |
| 118 | // if an icon was passed in using the ios or md attributes |
| 119 | // set the iconName to whatever was passed in |
| 120 | if (ios && mode === 'ios') { |
| 121 | iconName = toLower(ios); |
| 122 | } else if (md && mode === 'md') { |
| 123 | iconName = toLower(md); |
| 124 | } else { |
| 125 | if (!iconName && icon && !isSrc(icon)) { |
| 126 | iconName = icon; |
| 127 | } |
| 128 | if (isStr(iconName)) { |
| 129 | iconName = toLower(iconName); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | if (!isStr(iconName) || iconName.trim() === '') { |
| 134 | return null; |
| 135 | } |
| 136 | |
| 137 | // only allow alpha characters and dash |
| 138 | const invalidChars = iconName.replace(/[a-z]|-|\d/gi, ''); |
| 139 | if (invalidChars !== '') { |
| 140 | return null; |
| 141 | } |
| 142 | |
| 143 | return iconName; |
| 144 | }; |
| 145 | |
| 146 | export const getSrc = (src: string | undefined) => { |
| 147 | if (isStr(src)) { |