INNER CODE UNIT · TypeScript

companyDomain

rowboatlabs/rowboat · apps/harbor/packages/server/src/connectors/attio/index.ts:7

function companyDomain(args: string): string {
  const input = args.trim().replace(/\.$/, '');
  const invalid = () => new UsageError('Give a company domain, such as acme.com, without a URL path or email address.');
  if (!input || /[\s/:@?#%\\]/.test(input)) throw invalid();
  const domain = domainToASCII(input).toLowerCase();
  const labels = domain.split('.');
  if (domain.length > 253 || labels.length < 2 || /^\d+$/.test(labels.at(-1)!) ||
      labels.some((label) => !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label))) throw invalid();
  return domain;
}

function personEmail(args: string): string {
  const parts = args.trim().split('@');
  if (parts.length !== 2 || /[\s/:?#%\\]/.test(parts[1]!)) throw new UsageError('Give one email address, such as jane@acme.com.');
  const email = `${parts[0]}@${domainToASCII(parts[1]!)}`.toLowerCase();
  if (!z.email().safeParse(email).success || email.length > 254 || parts[0]!.length > 64) {
    throw new UsageError('Give one email address, such as jane@acme.com.');
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…