[object Object]

← back to Customdigitalmurals

render: route buy CTA + main-store anchor + card sample link through /buy/:slug (kill vendor-handle DOM leak; mirrors fleet a85eb02)

929a23cb6e72ab2658073b85df077326d0914900 · 2026-05-31 21:00:21 -0700 · Steve Abrams

Files touched

Diff

commit 929a23cb6e72ab2658073b85df077326d0914900
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sun May 31 21:00:21 2026 -0700

    render: route buy CTA + main-store anchor + card sample link through /buy/:slug (kill vendor-handle DOM leak; mirrors fleet a85eb02)
---
 server.js | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/server.js b/server.js
index 3196c49..bea7e10 100644
--- a/server.js
+++ b/server.js
@@ -265,6 +265,17 @@ app.get('/product/:handle', (req, res) => {
   res.send(productPage(p));
 });
 
+// /buy/:slug — internal 302 to the main store. Resolves a vendor-redacted slug
+// to the real handle SERVER-SIDE so the raw vendor-bearing handle never appears
+// in customer-facing HTML (mirrors dw-domain-fleet a85eb02). ?sample → #sample.
+app.get('/buy/:slug', (req, res) => {
+  const key = req.params.slug;
+  const p = ALL.find(x => x.handle === key) || ALL.find(x => redactVendorSlug(x.handle) === key);
+  if (!p) return res.status(404).send(page404());
+  const frag = req.query.sample != null ? '#sample' : '';
+  res.redirect(302, `${DW_BASE}/products/${p.handle}${frag}`);
+});
+
 // Homepage
 app.get('/', (_req, res) => res.send(homePage()));
 app.get('/sitemap.xml', (_req, res) => {
@@ -633,7 +644,7 @@ function load(){
           '<div class="card-vendor">Designer Wallcoverings</div>'+
           '<div class="card-title">'+esc(p.title)+'</div>'+
           (price?'<div class="card-price">'+price+'</div>':'')+
-          '<a class="card-sample" href="'+esc('https://designerwallcoverings.com/products/'+p.handle+'#sample')+'" onclick="event.stopPropagation()" target="_blank" rel="noopener noreferrer">Order Free Sample</a>'+
+          '<a class="card-sample" href="'+esc('/buy/'+(p.slug||p.handle)+'?sample=1')+'" onclick="event.stopPropagation()" target="_blank" rel="noopener noreferrer">Order Free Sample</a>'+
         '</div>'+
       '</div>';
     }).join('');
@@ -722,8 +733,8 @@ function productPage(p) {
   const imgs = p.images || [];
   const mainImg = imgs[0] || '';
   const price = parseFloat(p.price || 0) > 0 ? `$${parseFloat(p.price).toFixed(2)} / roll` : 'Contact for pricing';
-  const sampleUrl = `${DW_BASE}/products/${p.handle}#sample`;
-  const dwUrl = `${DW_BASE}/products/${p.handle}`;
+  const sampleUrl = `/buy/${redactVendorSlug(p.handle)}?sample=1`;
+  const dwUrl = `/buy/${redactVendorSlug(p.handle)}`;
 
   // Strip HTML tags from body for safe display
   const prose = (p.body_html || '')

← b4045d3 Add per-site favicon (kills /favicon.ico 404)  ·  back to Customdigitalmurals  ·  Scrub residual vendor names from products.json (title/vendor 13a98bb →