[object Object]

← back to Commercialrealestate

feat: clean extension-less URLs (/mls, /brokers, /map, etc.) alongside .html links

7f658fc163ae528d1f81d295ae977935d07f568f · 2026-07-01 09:58:42 -0700 · Steve Abrams

Files touched

Diff

commit 7f658fc163ae528d1f81d295ae977935d07f568f
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Jul 1 09:58:42 2026 -0700

    feat: clean extension-less URLs (/mls, /brokers, /map, etc.) alongside .html links
---
 scripts/serve.js | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/scripts/serve.js b/scripts/serve.js
index 193ea49..d1b1c8f 100644
--- a/scripts/serve.js
+++ b/scripts/serve.js
@@ -762,6 +762,16 @@ app.get('/api/broker-history', (req, res) => {
   } catch (e) { res.status(502).json({ error: String(e.message).split('\n')[0] }); }
 });
 
+// Clean URLs: serve public/<name>.html at /<name> (extension-less), so /mls, /brokers,
+// /map, /condos, etc. work alongside the existing .html links in the nav. GET-only, and
+// only when the extension-less path has no dot (skips /api, /data, and real asset files).
+app.get(/^\/[a-zA-Z0-9_-]+$/, (req, res, next) => {
+  const name = req.path.slice(1);
+  const html = path.join(ROOT, 'public', name + '.html');
+  if (fs.existsSync(html)) return res.sendFile(html);
+  next();
+});
+
 app.use('/data', express.static(path.join(ROOT, 'data')));
 app.use('/', express.static(path.join(ROOT, 'public')));
 

← b40a08b ops: launchd LaunchAgent for cre-viewer reboot persistence (  ·  back to Commercialrealestate  ·  chore: lint ✓ (clean, no linter) · refactor ✓ (no change) · 6be26bf →