From 2f635227aa3c17e8d5624949367586b09036955d Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 30 May 2026 23:07:52 -0500 Subject: [PATCH] improve name-check: match base name without entity suffix (LLC/Inc/Corp), flag close matches --- api/src/routes/dot-lookup.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/api/src/routes/dot-lookup.ts b/api/src/routes/dot-lookup.ts index e1797d3..d72b941 100644 --- a/api/src/routes/dot-lookup.ts +++ b/api/src/routes/dot-lookup.ts @@ -721,12 +721,21 @@ router.post("/api/v1/dot/name-check", async (req, res) => { // Parse FMCSA result let fmcsaMatches: Record[] = []; let fmcsaExactMatch = false; + let fmcsaCloseMatch = false; if (fmcsaResult.status === "fulfilled") { fmcsaMatches = fmcsaResult.value.rows || []; + const searchUpper = name.toUpperCase().replace(/\s+(LLC|INC|CORP|CORPORATION|LTD|LP|LLP|CO|COMPANY)\.?$/i, "").trim(); fmcsaExactMatch = fmcsaMatches.some( (r: Record) => (r.legal_name as string || "").toUpperCase() === name.toUpperCase(), ); + // Also check if the base name (without entity suffix) matches + if (!fmcsaExactMatch) { + fmcsaCloseMatch = fmcsaMatches.some((r: Record) => { + const legalUpper = (r.legal_name as string || "").toUpperCase().replace(/\s+(LLC|INC|CORP|CORPORATION|LTD|LP|LLP|CO|COMPANY)\.?$/i, "").trim(); + return legalUpper === searchUpper; + }); + } } res.json({ @@ -738,16 +747,18 @@ router.post("/api/v1/dot/name-check", async (req, res) => { entity_number: sosEntity.entity_number, entity_type: sosEntity.entity_type, } : null, - fmcsa_in_use: fmcsaExactMatch, + fmcsa_in_use: fmcsaExactMatch || fmcsaCloseMatch, fmcsa_matches: fmcsaMatches.slice(0, 10).map((r: Record) => ({ dot_number: r.dot_number, legal_name: r.legal_name, dba_name: r.dba_name, state: r.phy_state, })), - available: sosAvailable !== false && !fmcsaExactMatch, + available: sosAvailable !== false && !fmcsaExactMatch && !fmcsaCloseMatch, message: fmcsaExactMatch ? `"${name}" is already registered with FMCSA (DOT# ${(fmcsaMatches.find((r: Record) => (r.legal_name as string || "").toUpperCase() === name.toUpperCase()) as Record)?.dot_number}). Choose a different name or use your existing entity.` + : fmcsaCloseMatch + ? `A similar name is already registered with FMCSA: "${(fmcsaMatches[0] as Record)?.legal_name}" (DOT# ${(fmcsaMatches[0] as Record)?.dot_number}). This may cause confusion — consider a more distinct name.` : sosAvailable === false ? `"${name}" is already registered in ${stateCode}. The name may still be usable if it's your entity.` : sosAvailable === true