Name and Domain Matching Utilities (lib/names.ts)

mperkins0155/crm · crm, CRM / Leads, name-matching, domain, email, utils

Utility functions to generate search terms, compare company names, and extract domains for contact matching.

// Source: https://github.com/mperkins0155/crm | License: MIT | Copyright 2026 Comp AI
// Provided via justclaw.it.com; keep this notice with the code.
export function searchTerms(local: string): string[] {
	const handle = local.toLowerCase().replace(/[^a-z0-9._-]/g, "");
	const terms: string[] = [];

	const add = (term: string) => {
		if (term.length >= 3 && !terms.includes(term)) terms.push(term);
	};

	const parts = handle.split(/[._-]+/).filter(Boolean);
	if (parts.length > 1) {
		add(parts.join(" "));
		add(parts[parts.length - 1] as string);
	}

	add(handle);

	if (parts.length === 1) {
		add(handle.slice(1));
		add(handle.slice(2));
	}

	return terms;
}

export function looksLikeSameCompany(
	employer: string,
	companyName: string,
	domain: string,
): boolean {
	const a = normalise(

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key