mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-05-20 18:24:20 +00:00
require strict parents for every level + fix ns on nested subdomains with ns
This commit is contained in:
+15
-9
@@ -24,26 +24,32 @@ function getDomainData(subdomain) {
|
||||
t("Nested subdomains should not exist without a parent subdomain", (t) => {
|
||||
files.forEach((file) => {
|
||||
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(
|
||||
parentDomain && files.includes(`${parentDomain}.json`),
|
||||
`${file}: Parent subdomain does not exist`
|
||||
files.includes(`${parent}.json`),
|
||||
`${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) => {
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
const parentDomain = subdomain.split(".").reverse()[0];
|
||||
const parts = subdomain.split(".");
|
||||
|
||||
if (parentDomain !== subdomain) {
|
||||
const parentData = getDomainData(parentDomain);
|
||||
for (let i = 1; i < parts.length; i++) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user