← back to Marketing Command Center
lib/kravet.js
40 lines
'use strict';
// Canonical Kravet-family brand block — single source of truth.
// Reposting brand-controlled (Kravet-umbrella) imagery under the DW account is
// hard-blocked per Steve's standing rule. Both the server repost gate AND the
// client repost modal read this list (the client fetches it via
// GET /api/assets/repost-policy) so the two can never drift apart again.
//
// Keep this list in sync with the Kravet-family pricing rule in MEMORY.md
// (kravet-lines-price-at-map).
const KRAVET_BRANDS = [
'kravet', 'lee jofa', 'lee jofa modern', 'groundworks', 'brunschwig',
'cole & son', 'cole and son', 'gp & j baker', 'gp&j baker', 'g p & j baker',
'colefax', 'clarke & clarke', 'clarke and clarke', 'clarke', 'mulberry',
'threads', 'baker lifestyle', 'andrew martin', 'nicolette mayer', 'aerin',
'barclay butera', 'thom filicia',
];
// One regex, built from the list. Spaces are matched loosely (any whitespace,
// optional surrounding) and "&"/"and" are treated as interchangeable so handles
// like @coleandson, @cole_and_son, "Cole & Son" all match.
// Tokens are joined by ANY separator (space, _, -, .) or none, so handle forms
// like "@cole_and_son", "@lee-jofa", "Cole & Son" and "coleandson" all match.
const KRAVET_RE = new RegExp(
KRAVET_BRANDS
.map(b => b
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') // escape regex metachars
.replace(/\s*(&|and)\s*/gi, '[\\s_.-]*(?:&|and)?[\\s_.-]*') // & / and / nothing
.replace(/\s+/g, '[\\s_.-]*')) // loose internal separators
.join('|'),
'i',
);
// True if ANY of the supplied strings (handle, caption, asset name, tags…)
// reference a brand-controlled line.
function isKravet(...strings) {
return strings.some(s => s && KRAVET_RE.test(String(s)));
}
module.exports = { KRAVET_BRANDS, KRAVET_RE, isKravet };