All files / src/utils eventLocation.ts

90.9% Statements 10/11
50% Branches 2/4
100% Functions 4/4
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 2111x 234x       234x   502x     234x   815x     234x 227x     7x  
export function formatEventLocation(address?: string | null): string {
  Iif (!address) {
    return 'Location not specified';
  }
 
  const parts = address
    .split(',')
    .map((part) => part.trim())
    .filter(Boolean);
 
  const uniqueParts = parts.filter(
    (part, index) =>
      index === parts.findIndex((p) => p.toLowerCase() === part.toLowerCase()),
  );
 
  if (uniqueParts.length >= 2) {
    return `${uniqueParts[0]}, ${uniqueParts[1]}`;
  }
 
  return uniqueParts[0] ?? 'Location not specified';
}