Browse Source

fix(ui): Safely access avatar string (#25409)

Scott Cooper 3 years ago
parent
commit
1b1e34d592
1 changed files with 3 additions and 1 deletions
  1. 3 1
      static/app/components/letterAvatar.tsx

+ 3 - 1
static/app/components/letterAvatar.tsx

@@ -41,7 +41,9 @@ function getColor(identifier: string | undefined): Color {
 }
 
 function getInitials(displayName: string | undefined) {
-  const names = ((displayName && displayName.trim()) || '?').split(' ');
+  const names = ((typeof displayName === 'string' && displayName.trim()) || '?').split(
+    ' '
+  );
   // Use Array.from as slicing and substring() work on ucs2 segments which
   // results in only getting half of any 4+ byte character.
   let initials = Array.from(names[0])[0];