[object Object]

← back to Dw Domain Fleet

render.js scrubVendor: fix regex builder (split on non-alnum + drop empty tokens — was mangling 'brunschwig & fils' → '-fils' residue) + add slug variants cole-son/caroline-cecil/clarke-clarke/morris-co so /product hrefs are fully vendor-clean (DTD verdict A)

9450ca4a88a7b090abe344d21f83ae035c8e57e4 · 2026-05-29 22:30:31 -0700 · Steve

Files touched

Diff

commit 9450ca4a88a7b090abe344d21f83ae035c8e57e4
Author: Steve <steve@designerwallcoverings.com>
Date:   Fri May 29 22:30:31 2026 -0700

    render.js scrubVendor: fix regex builder (split on non-alnum + drop empty tokens — was mangling 'brunschwig & fils' → '-fils' residue) + add slug variants cole-son/caroline-cecil/clarke-clarke/morris-co so /product hrefs are fully vendor-clean (DTD verdict A)
---
 shared/render.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/shared/render.js b/shared/render.js
index 04fa3ee..51cad91 100644
--- a/shared/render.js
+++ b/shared/render.js
@@ -75,10 +75,15 @@ function scrubTags(tags) {
  * cleaning the slug never breaks a product link. (2026-05-29 fleet vendor-leak
  * audit: slug/handle + visible card-title vector.) */
 const _VENDOR_SCRUB = VENDORS_DENYLIST
-  .concat(['brunschwig and fils', 'brunschwig & fils', 'lee jofa modern',
-           'gp j baker', 'cole and son', 'clarke and clarke', 'morris and co'])
+  .concat(['brunschwig fils', 'lee jofa modern', 'gp j baker',
+           'cole and son', 'cole son', 'clarke and clarke', 'clarke clarke',
+           'morris and co', 'morris co', 'caroline cecil textiles', 'caroline cecil'])
   .slice().sort((a, b) => b.length - a.length)
-  .map(v => new RegExp('\\b' + v.split(/\s+/).map(w => w.replace(/[^a-z0-9]/gi, '')).join('[^a-z0-9]+') + '\\b', 'ig'));
+  // Split on ANY non-alphanumeric run and drop empties, so each vendor's word
+  // tokens join with a flexible separator — matches "Brunschwig & Fils" (title)
+  // AND "brunschwig-fils" (slug). (The old \s+ split left an empty token for the
+  // "&" → a double-separator regex that failed on single-hyphen handles.)
+  .map(v => new RegExp('\\b' + v.split(/[^a-z0-9]+/i).filter(Boolean).join('[^a-z0-9]+') + '\\b', 'ig'));
 function scrubVendor(s) {
   if (s == null) return s;
   let o = String(s);

← 09c24d7 render.js: scrubVendor() removes vendor names from displayed  ·  back to Dw Domain Fleet  ·  render.js productSlug: when the whole handle is a vendor nam 52a5b40 →