← back to Marketing Command Center
lib/leak-deny.js
29 lines
// Private-label LEAK guard — shared across the marketing stack so no upstream/true
// vendor name ever surfaces customer-facing (captions, hashtags, product titles).
// These are private-label lines whose real supplier must NEVER appear publicly.
// Mirrors dw-marketing-reels/scripts/build-reel.mjs (LEAK_DENY + clean()) and the
// dw-leak-scanner denylist. Copy of the reel's regex + clean() approach.
//
// Usage:
// const { LEAK_DENY, clean, isLeaky } = require('../lib/leak-deny');
// if (isLeaky(caption)) … // does ANY denylisted name appear?
// const safeCaption = clean(caption); // strip any denylisted word out
// Denylist regex — the upstream vendor names that must stay private-label.
const LEAK_DENY = /greenland|wallquest|chesapeake|nextwall|seabrook|brewster|command\s*54|momentum|versa|desima|carlsten|nicolette\s*mayer|york\s*wall/i;
// isLeaky(s) — true if the string contains any denylisted upstream name.
function isLeaky(s) {
return !!s && LEAK_DENY.test(String(s));
}
// clean(s) — final safety net: drop any whitespace-delimited word that matches
// the denylist, so a single leaked token can't ride along in an otherwise-safe
// string. Returns the scrubbed string (empty string for null/undefined input).
function clean(s) {
if (s == null) return '';
return String(s).split(/\s+/).filter(w => !LEAK_DENY.test(w)).join(' ');
}
module.exports = { LEAK_DENY, clean, isLeaky };