All files / src/utils eventLocation.ts

88.23% Statements 15/17
77.77% Branches 7/9
100% Functions 1/1
88.23% Lines 15/17

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 23  1x 36x       36x 36x 36x 36x   36x 36x 41x 36x   36x 4x 4x   33x 36x  
/** First two comma-separated parts (e.g. district, city), deduplicated — matches mobile `formatEventLocation`. */
export function formatEventLocation(address?: string | null): string {
  if (!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';
}