[object Object]

← back to All Designerwallcoverings

keep internal vendor hostnames within DNS limits

9cd80aece7a6b0ff5d8b2ace4ce51452a8b074d8 · 2026-08-28 09:51:30 -0700 · Steve Abrams

Files touched

Diff

commit 9cd80aece7a6b0ff5d8b2ace4ce51452a8b074d8
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Fri Aug 28 09:51:30 2026 -0700

    keep internal vendor hostnames within DNS limits
---
 lib/vendor-pairs.js       | 5 ++++-
 test/vendor-pairs.test.js | 6 ++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/vendor-pairs.js b/lib/vendor-pairs.js
index d692ef3..fcc1bd2 100644
--- a/lib/vendor-pairs.js
+++ b/lib/vendor-pairs.js
@@ -4,7 +4,10 @@ const hostSlugify = (value) => String(value || '').toLowerCase().normalize('NFD'
   .replace(/[\u0300-\u036f]/g, '')
   .replace(/&/g, ' and ')
   .replace(/[^a-z0-9]+/g, '-')
-  .replace(/^-+|-+$/g, '');
+  .replace(/^-+|-+$/g, '')
+  // One DNS label is capped at 63 bytes. Reserve nine characters for the
+  // required "-internal" twin and never leave a trailing separator.
+  .slice(0, 54).replace(/-+$/g, '');
 
 function buildVendorPairSeeds(vendors) {
   const seen = new Set();
diff --git a/test/vendor-pairs.test.js b/test/vendor-pairs.test.js
index e4ce46f..becb090 100644
--- a/test/vendor-pairs.test.js
+++ b/test/vendor-pairs.test.js
@@ -10,6 +10,12 @@ test('hostname slug keeps words readable and stable', () => {
   assert.equal(hostSlugify('Coordonn\u00e9 Europe'), 'coordonne-europe');
 });
 
+test('hostname slug always leaves room for the internal suffix', () => {
+  const slug = hostSlugify('Lincrusta Embossed Paintable Dados Walls Frieze Borders');
+  assert.ok(`${slug}-internal`.length <= 63);
+  assert.equal(slug.length, 54);
+});
+
 test('every unified vendor expands to public and internal records', () => {
   const rows = buildVendorPairSeeds([{ name: 'Astek', active_count: 12, images: ['hero.jpg'], created_at: '2026-01-02T03:04:00Z' }]);
   assert.deepEqual(rows.map((r) => r.slug), ['astek', 'astek-internal']);

← 30003d2 probe shared vendor pairs without downloading duplicate feed  ·  back to All Designerwallcoverings  ·  record complete unified vendor endpoint proof 2752be2 →