Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

541 B
Raw Blame
export function getFirstName(name: string | null | undefined) {
  if (!name) return '';
  if (name.toLowerCase().startsWith('the ')) return name.replace(/,+$/, '');

  const trimmed = name.trim();

  // Handle "LastName, FirstName [MiddleInitial]" format (common in Outlook)
  if (trimmed.includes(',')) {
    const [, rest] = trimmed.split(',', 2);
    if (rest) {
      const firstName = rest.trim().split(/\s+/)[0];
      if (firstName) return firstName.replace(/,+$/, '');
    }
  }

  return trimmed.split(' ')[0].replace(/,+$/, '');
}