← back to Rentv 2026
harden(deals): Cody gate — lookbehind so period-cut spares St./Mt./Ft. cities; narrow title-state to CA|AZ|NV|TX|WA so OR/ID/CO title tokens can't null a correct city
db6ec30d5b172f4cebfe2acd2cd266069479358b · 2026-08-06 06:04:27 -0700 · Steve
Files touched
M scripts/lib/parse-location.mjs
Diff
commit db6ec30d5b172f4cebfe2acd2cd266069479358b
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Aug 6 06:04:27 2026 -0700
harden(deals): Cody gate — lookbehind so period-cut spares St./Mt./Ft. cities; narrow title-state to CA|AZ|NV|TX|WA so OR/ID/CO title tokens can't null a correct city
---
scripts/lib/parse-location.mjs | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/scripts/lib/parse-location.mjs b/scripts/lib/parse-location.mjs
index ad58838f..5f4837d5 100644
--- a/scripts/lib/parse-location.mjs
+++ b/scripts/lib/parse-location.mjs
@@ -27,8 +27,11 @@ const tidy = (c) => {
c = clean(c)
// Drop a next-SENTENCE word the capture swallowed across a period ("Sunnyvale. Located" → "Sunnyvale").
// The "in <City>" / lead char class allows '.', so a sentence-ending period + the following capitalized
- // word (e.g. "…in Sunnyvale. Located at 1200 Kifer Rd…") got glued into a bogus two-word city.
- .replace(/\.\s+\S.*$/, '')
+ // word (e.g. "…in Sunnyvale. Located at 1200 Kifer Rd…") got glued into a bogus two-word city. The
+ // lookbehind requires 3+ lowercase letters before the period so it fires only on a real word-ending
+ // period ("Sunnyvale.", "Oakland.") — never on an abbreviation prefix like "St."/"Mt."/"Ft." (which
+ // would otherwise be truncated to a <3-char stub and nulled, dropping St. Helena / Mt. Shasta cities).
+ .replace(/(?<=[a-z]{3,})\.\s+\S.*$/, '')
.replace(/\s+(Res|Metro|Area|Region|Residential|Portfolio|Community|Property|Properties|Industrial|Office|Retail|Facility|Facilities|Holdings|Assets|Buy|Sale|Deal)$/i, '');
const first = (c.split(' ')[0] || '');
return (!c || c.length < 3 || FIRM_ADJ.test(c) || NOT_CITY.test(first) || NOT_CITY.test(c)) ? null : c;
@@ -48,10 +51,13 @@ const CITY_STATE = {
const STATE_OF = {};
for (const [st, cities] of Object.entries(CITY_STATE)) for (const c of cities) STATE_OF[c.toLowerCase()] = st;
-// Unambiguous 2-letter state abbreviations that reliably mean THE STATE in a CRE headline. Full
-// names are deliberately excluded — "Colorado"/"Washington"/"Oregon" double as street/place names
-// (Colorado Blvd, Washington St), so they'd mis-fire; two-cap standalone tokens don't.
-const TITLE_ST = /\b(AZ|CA|NV|TX|CO|OR|WA|NM|UT|ID)\b/;
+// Unambiguous 2-letter state abbreviations that reliably mean THE STATE in a CRE headline. Full state
+// names are excluded (Colorado Blvd / Washington St / etc. double as place names). We also exclude the
+// abbreviations that collide with ordinary title tokens — OR (the conjunction "OR"), ID ("Asset ID
+// 44291"), CO (a company suffix like "GlobalTech CO"), plus NM/UT — since those would null a correctly
+// resolved city and assign the wrong state. The kept 5 are RENTV's core coverage AND collision-free as
+// standalone uppercase tokens; OR/CO deals still resolve via the priority-1 "City, ST" rule ("Portland, OR").
+const TITLE_ST = /\b(CA|AZ|NV|TX|WA)\b/;
export function parseLocation(title = '', body = '') {
const r = _parseLocation(title, body);
← d088ba4f fix(deals): two location misparses — trust explicit title st
·
back to Rentv 2026
·
auto-save: 2026-08-06T06:19:10 (7 files) — data/deals-regist 71c6cae2 →