require strict parents for every level + fix ns on nested subdomains with ns

This commit is contained in:
William Harrison authored and GitHub committed 2025-04-04 11:56:05 +08:00
1 parent 2d3e44addb
commit b6bb69f110
1 file changed
+15 -9
+15 -9
View File
@@ -24,26 +24,32 @@ function getDomainData(subdomain) {
t("Nested subdomains should not exist without a parent subdomain", (t) => { t("Nested subdomains should not exist without a parent subdomain", (t) => {
files.forEach((file) => { files.forEach((file) => {
const subdomain = file.replace(/\.json$/, ""); const subdomain = file.replace(/\.json$/, "");
const parentDomain = subdomain.split(".").reverse()[0]; const parts = subdomain.split(".");
if (parentDomain !== subdomain) { for (let i = 1; i < parts.length; i++) {
const parent = parts.slice(i).join(".");
t.true( t.true(
parentDomain && files.includes(`${parentDomain}.json`), files.includes(`${parent}.json`),
`${file}: Parent subdomain does not exist` `${file}: Parent subdomain "${parent}" does not exist`
); );
} }
}); });
}); });
t("Nested subdomains should not exist if the parent subdomain has NS records", (t) => { t("Nested subdomains should not exist if any parent subdomain has NS records", (t) => {
files.forEach((file) => { files.forEach((file) => {
const subdomain = file.replace(/\.json$/, ""); const subdomain = file.replace(/\.json$/, "");
const parentDomain = subdomain.split(".").reverse()[0]; const parts = subdomain.split(".");
if (parentDomain !== subdomain) { for (let i = 1; i < parts.length; i++) {
const parentData = getDomainData(parentDomain); const parent = parts.slice(i).join(".");
const parentData = getDomainData(parent);
t.true(!parentData.record.NS, `${file}: Parent subdomain has NS records`); if (!parentData) continue;
if (parentData.record.NS) {
t.fail(`${file}: Parent subdomain "${parent}" has NS records`);
return;
}
} }
}); });
}); });