mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-14 06:17:53 +00:00
remove @ + www json files, update reserved
This commit is contained in:
1 parent
3fd2839c98
commit
964fd4b060
6 files changed
+24
-123
No files matched your search
+14
-16
@@ -97,25 +97,23 @@ async function validateFileName(t, file) {
|
||||
t.false(file.includes("--"), `${file}: File name should not contain consecutive hyphens`);
|
||||
t.false(file.startsWith("_redirect."), `${file}: File name should not start with _redirect`);
|
||||
|
||||
if (file !== "@.json") {
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
|
||||
t.regex(
|
||||
subdomain + ".is-a.dev",
|
||||
hostnameRegex,
|
||||
`${file}: FQDN must be 1-253 characters, can use letters, numbers, dots, and non-consecutive hyphens.`
|
||||
);
|
||||
t.false(reservedDomains.includes(subdomain), `${file}: Subdomain name is reserved`);
|
||||
t.true(
|
||||
!reservedDomains.some((reserved) => subdomain.endsWith(`.${reserved}`)),
|
||||
`${file}: Subdomain name is reserved`
|
||||
);
|
||||
t.regex(
|
||||
subdomain + ".is-a.dev",
|
||||
hostnameRegex,
|
||||
`${file}: FQDN must be 1-253 characters, can use letters, numbers, dots, and non-consecutive hyphens.`
|
||||
);
|
||||
t.false(reservedDomains.includes(subdomain), `${file}: Subdomain name is reserved`);
|
||||
t.true(
|
||||
!reservedDomains.some((reserved) => subdomain.endsWith(`.${reserved}`)),
|
||||
`${file}: Subdomain name is reserved`
|
||||
);
|
||||
|
||||
const rootSubdomain = subdomain.split(".").pop();
|
||||
const rootSubdomain = subdomain.split(".").pop();
|
||||
|
||||
if (!excludedDomains.includes(rootSubdomain)) {
|
||||
t.false(rootSubdomain.startsWith("_"), `${file}: Root subdomains should not start with an underscore`);
|
||||
}
|
||||
if (!excludedDomains.includes(rootSubdomain)) {
|
||||
t.false(rootSubdomain.startsWith("_"), `${file}: Root subdomains should not start with an underscore`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,11 +147,9 @@ function validateRecordValues(t, data, file) {
|
||||
);
|
||||
t.notThrows(() => new URL(value), `${file}: Invalid URL for ${key}`);
|
||||
|
||||
// Check for self-referencing redirects
|
||||
const urlHost = new URL(value).host;
|
||||
const isSelfReferencing =
|
||||
file === "@.json" ? urlHost === "is-a.dev" : urlHost === `${subdomain}.is-a.dev`;
|
||||
|
||||
t.false(isSelfReferencing, `${file}: URL cannot point to itself`);
|
||||
t.false(urlHost === `${subdomain}.is-a.dev`, `${file}: URL cannot point to itself`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,8 +262,7 @@ function validateRecordValues(t, data, file) {
|
||||
|
||||
// Check for self-referencing redirects
|
||||
const urlHost = new URL(customRedirectURL).host;
|
||||
const isSelfReferencing = file === "@.json" ? urlHost === "is-a.dev" : urlHost === `${subdomain}.is-a.dev`;
|
||||
t.false(isSelfReferencing, `${urlMessage} cannot point to itself at index ${idx}`);
|
||||
t.false(urlHost === `${subdomain}.is-a.dev`, `${urlMessage} cannot point to itself at index ${idx}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user