parent
e1edce4da0
commit
10d3bbefa4
2 changed files with 32 additions and 2 deletions
|
|
@ -4,7 +4,8 @@ import path from "node:path";
|
||||||
const repoRoot = process.cwd();
|
const repoRoot = process.cwd();
|
||||||
const distRoot = path.join(repoRoot, "dist");
|
const distRoot = path.join(repoRoot, "dist");
|
||||||
const htmlAttributes = ["href", "src", "poster", "action"];
|
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([
|
const assetExtensions = new Set([
|
||||||
".avif",
|
".avif",
|
||||||
".css",
|
".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);
|
const reference = normalizeReference(rawReference);
|
||||||
|
|
||||||
if (!reference) {
|
if (!reference) {
|
||||||
|
|
@ -150,6 +161,25 @@ function checkReference({ sourceFile, rawReference, sourceKind }) {
|
||||||
return 1;
|
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) {
|
function isInternalHtmlPageReference(rawReference) {
|
||||||
const trimmed = rawReference.trim();
|
const trimmed = rawReference.trim();
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -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;
|
const ignoredProtocolPattern = /^(?:mailto|tel|javascript|data|blob):/i;
|
||||||
|
|
||||||
function splitSuffix(value: string): { pathname: string; suffix: string } {
|
function splitSuffix(value: string): { pathname: string; suffix: string } {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue