From cd363b484016c82f1ce7485e8e96350f2d863814 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Thu, 7 May 2026 17:43:02 +0200 Subject: [PATCH] fix: strip leading punctuation when computing avatar initials --- components/ui/avatar.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx index 11ec1e3f..7b604da7 100644 --- a/components/ui/avatar.tsx +++ b/components/ui/avatar.tsx @@ -189,10 +189,17 @@ export function Avatar({ name, email, contactPhotoUri, size = "md", className, d const getInitials = () => { if (name) { - const parts = name.trim().split(/\s+/); + const parts = name + .trim() + .split(/\s+/) + .map((p) => p.replace(/^[^\p{L}\p{N}]+/u, "")) + .filter((p) => p.length > 0); if (parts.length >= 2) { return `${parts[0][0]}${parts[parts.length - 1][0]}`.toUpperCase(); } + if (parts.length === 1) { + return parts[0].slice(0, 2).toUpperCase(); + } return name.slice(0, 2).toUpperCase(); } if (email) {