[object Object]

← back to Rentv 2026

harden(dealdesk): Cody gate — coveredBy matches the needle segment as a WHOLE WORD (not substring), fixing the sf→transfers false-cover (27 titles) AND recovering legit short-firm coverage (CBRE→2 real matches) a length threshold would drop; <4-char floor drops state/initialism noise. (Verified Cody's >4-substring would've reintroduced hines∈machines)

f47b2a5770400e5cd35bb81d7d71a663192b2445 · 2026-08-06 09:58:40 -0700 · Steve

Files touched

Diff

commit f47b2a5770400e5cd35bb81d7d71a663192b2445
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu Aug 6 09:58:40 2026 -0700

    harden(dealdesk): Cody gate — coveredBy matches the needle segment as a WHOLE WORD (not substring), fixing the sf→transfers false-cover (27 titles) AND recovering legit short-firm coverage (CBRE→2 real matches) a length threshold would drop; <4-char floor drops state/initialism noise. (Verified Cody's >4-substring would've reintroduced hines∈machines)
---
 server.js | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/server.js b/server.js
index 34efed31..341561eb 100644
--- a/server.js
+++ b/server.js
@@ -1140,10 +1140,19 @@ app.post('/api/dealdesk/find', adminOnly, async (req, res) => {
   const arch = readJSON('news-archive.json', []); const items = Array.isArray(arch) ? arch : (arch.items || []);
   const coveredBy = (deal) => {
     const needle = [deal.address, deal.buyer, deal.seller, deal.headline || deal.title].filter(Boolean).map((s) => String(s).toLowerCase());
-    // Guard the length of the SEGMENT actually matched, not the whole needle — else a needle like
-    // "SF, CA 94105" (len 12) passes the >8 check but matches on the 2-char "sf", which substring-hits
-    // "tranSFers"/"satiSFied" and falsely marks a deal already-covered (skipping a good candidate).
-    return items.find((a) => { const t = String(a.title || '').toLowerCase(); return needle.some((n) => { const seg = n.split(',')[0].trim(); return seg.length > 8 && t.includes(seg); }); });
+    // Match the needle's leading segment as a WHOLE WORD (not a substring) so "sf" (from "SF, CA 94105")
+    // doesn't hit "tranSFers" — the old `t.includes(seg)` substring-matched 27 unrelated archive titles.
+    // Word-boundary also RECOVERS legit short firm coverage a length-threshold would drop: needle "CBRE"
+    // matches the 2 real CBRE archive titles as a token, without false-hitting longer words. The <4 floor
+    // drops 2–3 char state/initialism noise (sf/ca/az/kkr) that's ambiguous even as a whole word.
+    return items.find((a) => {
+      const t = String(a.title || '').toLowerCase();
+      return needle.some((n) => {
+        const seg = n.split(',')[0].trim();
+        if (seg.length < 4) return false;
+        return new RegExp('\\b' + seg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\b').test(t);
+      });
+    });
   };
   // ── Gemini path (opt-in, paid) — only when explicitly requested AND a key exists.
   if (b.engine === 'gemini' && GEMINI_KEY) {

← 8c370f63 fix(dealdesk): coveredBy guards the matched SEGMENT length,  ·  back to Rentv 2026  ·  News map: collapse ALL controls into one LEFT hamburger; str 0044e5f8 →