All files / utils avatar.ts

90% Statements 9/10
50% Branches 2/4
100% Functions 3/3
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 238x   20x 20x 20x     41x 41x         41x       41x   64x      
const DICEBEAR_AVATAR_BASE_URL = "https://api.dicebear.com/7.x/adventurer/svg";
 
export function getAvatarUrl(seedValue: string) {
  const seed = encodeURIComponent(seedValue.trim().toLowerCase());
  return `${DICEBEAR_AVATAR_BASE_URL}?seed=${seed}`;
}
 
export function getInitialsFromName(name: string) {
  const words = name
    .trim()
    .split(/\s+/)
    .filter(Boolean);
 
  Iif (words.length === 0) {
    return "U";
  }
 
  return words
    .slice(0, 2)
    .map((word) => word[0]?.toUpperCase() ?? "")
    .join("");
}