From 10d3bbefa47299f877520dc99c13f361434c3e1d Mon Sep 17 00:00:00 2001 From: Loyyd Date: Wed, 8 Jul 2026 11:16:55 +0200 Subject: [PATCH] no bcgen domain --- scripts/audit-static-links.mjs | 32 +++++++++++++++++++++++++++++++- src/lib/urls.ts | 2 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/scripts/audit-static-links.mjs b/scripts/audit-static-links.mjs index d709be1f..b8402bb5 100644 --- a/scripts/audit-static-links.mjs +++ b/scripts/audit-static-links.mjs @@ -4,7 +4,8 @@ import path from "node:path"; const repoRoot = process.cwd(); const distRoot = path.join(repoRoot, "dist"); const htmlAttributes = ["href", "src", "poster", "action"]; -const internalHosts = new Set(["familyfed.ie", "www.familyfed.ie", "familyfed.bcgen.ie"]); +const internalHosts = new Set(["familyfed.ie"]); +const forbiddenSiteHosts = new Set(["familyfed.bcgen.ie", "www.familyfed.ie"]); const assetExtensions = new Set([ ".avif", ".css", @@ -108,6 +109,16 @@ function checkReference({ sourceFile, rawReference, sourceKind }) { }); } + const forbiddenHost = getForbiddenSiteHost(rawReference); + if (forbiddenHost) { + problems.push({ + sourceFile, + sourceKind, + rawReference, + reason: `site URLs must use familyfed.ie, not ${forbiddenHost}`, + }); + } + const reference = normalizeReference(rawReference); if (!reference) { @@ -150,6 +161,25 @@ function checkReference({ sourceFile, rawReference, sourceKind }) { return 1; } +function getForbiddenSiteHost(rawReference) { + if (!rawReference) { + return ""; + } + + const trimmed = rawReference.trim(); + if (!trimmed) { + return ""; + } + + try { + const url = new URL(trimmed.startsWith("//") ? `https:${trimmed}` : trimmed); + const host = url.hostname.toLowerCase(); + return forbiddenSiteHosts.has(host) ? host : ""; + } catch { + return ""; + } +} + function isInternalHtmlPageReference(rawReference) { const trimmed = rawReference.trim(); if ( diff --git a/src/lib/urls.ts b/src/lib/urls.ts index 1dc3edf9..e8d3935c 100644 --- a/src/lib/urls.ts +++ b/src/lib/urls.ts @@ -1,4 +1,4 @@ -const internalHosts = new Set(["familyfed.ie", "www.familyfed.ie", "familyfed.bcgen.ie"]); +const internalHosts = new Set(["familyfed.ie"]); const ignoredProtocolPattern = /^(?:mailto|tel|javascript|data|blob):/i; function splitSuffix(value: string): { pathname: string; suffix: string } {