From 977f2bf98e5b57b2ee2833ea5a2226cf17031514 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Sat, 14 Mar 2026 12:43:39 -0700 Subject: [PATCH] Clean up restaurant name and city from Toast/order.online imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Strip common suffixes like "Order pickup and delivery" and embedded street addresses from business names. Clean city field when it contains state/zip/country (e.g. "Santa Monica, CA 90405, USA" → "Santa Monica"). Fixes applied in both CFML parser and JS frontend as safety net. Co-Authored-By: Claude Opus 4.6 --- api/setup/analyzeMenuUrl.cfm | 38 ++++++++++++++++++++++++++++-------- portal/setup-wizard.html | 14 +++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/api/setup/analyzeMenuUrl.cfm b/api/setup/analyzeMenuUrl.cfm index 5642aba..954dc09 100644 --- a/api/setup/analyzeMenuUrl.cfm +++ b/api/setup/analyzeMenuUrl.cfm @@ -2037,15 +2037,37 @@ - - - - - + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + diff --git a/portal/setup-wizard.html b/portal/setup-wizard.html index 28684f6..db07e72 100644 --- a/portal/setup-wizard.html +++ b/portal/setup-wizard.html @@ -2079,12 +2079,26 @@ console.log('Business data:', biz); + // Clean business name: strip ordering-site suffixes and embedded address + let bizDisplayName = (biz.name || '').trim(); + bizDisplayName = bizDisplayName.replace(/\s*[-–—|]\s*(Order\s+(pickup|online|delivery|food)|Online\s+Order|Delivery\s*[&and]+\s*Takeout|Takeout\s*[&and]+\s*Delivery|Menu\s*[&and]+\s*Order).*$/i, ''); + if (biz.addressLine1 && bizDisplayName.toLowerCase().includes(biz.addressLine1.toLowerCase())) { + bizDisplayName = bizDisplayName.replace(new RegExp(biz.addressLine1.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i'), '').trim(); + } + bizDisplayName = bizDisplayName.replace(/[-–—|]+$/, '').replace(/^[-–—|]+/, '').trim(); + biz.name = bizDisplayName || biz.name; + // Parse address into components if it's a single string let addressLine1 = biz.addressLine1 || ''; let city = biz.city || ''; let state = biz.state || ''; let zip = biz.zip || ''; + // Clean city: if it contains commas (e.g. "Santa Monica, CA 90405, USA"), take just the city part + if (city.includes(',')) { + city = city.split(',')[0].trim(); + } + if (biz.address && !addressLine1) { console.log('Parsing address:', biz.address);