Skip to content

Commit 070ae0c

Browse files
committed
chore(uui-avatar): update code from typescript 4.8 to 4.9
1 parent 04b645e commit 070ae0c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

packages/uui-avatar/lib/uui-avatar.element.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,22 @@ export class UUIAvatarElement extends LitElement {
102102
private createInitials(name: string) {
103103
let initials = '';
104104

105-
if (name) {
106-
const words = name.match(/(\w+)/g) || [];
107-
initials = words[0].substring(0, 1);
108-
if (words.length > 1) {
109-
initials += words[words.length - 1].substring(0, 1);
110-
}
105+
if (!name) {
106+
return initials;
107+
}
108+
109+
const words = name.match(/(\w+)/g);
110+
111+
if (!words?.length) {
112+
return initials;
111113
}
114+
115+
initials = words[0].substring(0, 1);
116+
117+
if (words.length > 1) {
118+
initials += words[words.length - 1].substring(0, 1);
119+
}
120+
112121
return initials.toUpperCase();
113122
}
114123

0 commit comments

Comments
 (0)