MCPcopy
hub / github.com/ionic-team/ionicons / getName

Function getName

src/components/icon/utils.ts:108–144  ·  view source on GitHub ↗
(
  iconName: string | undefined,
  icon: string | undefined,
  mode: string | undefined,
  ios: string | undefined,
  md: string | undefined,
)

Source from the content-addressed store, hash-verified

106};
107
108export 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
146export const getSrc = (src: string | undefined) => {
147 if (isStr(src)) {

Callers 3

loadIconMethod · 0.90
utils.spec.tsFile · 0.90
getUrlFunction · 0.85

Calls 3

toLowerFunction · 0.85
isSrcFunction · 0.85
isStrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…