mirror of
https://github.com/tiennm99/open-domains.git
synced 2026-10-14 16:17:45 +00:00
Update domains.test.js
This commit is contained in:
1 parent
f6fe834af0
commit
fcd618090c
1 file changed
+17
-2
+17
-2
@@ -1,3 +1,18 @@
|
||||
const t = require("ava");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
|
||||
const domainsPath = path.resolve("domains");
|
||||
const files = fs.readdirSync(domainsPath);
|
||||
|
||||
// Extract valid root domains dynamically from the files, ignoring specific TLDs
|
||||
const validRootDomains = Array.from(
|
||||
new Set(
|
||||
files
|
||||
.map((file) => file.split(".").slice(-2).join("."))
|
||||
)
|
||||
);
|
||||
|
||||
t("Nested subdomains should not exist without a valid parent domain", (t) => {
|
||||
files.forEach((file) => {
|
||||
// Skip directories and process only .json files
|
||||
@@ -13,7 +28,7 @@ t("Nested subdomains should not exist without a valid parent domain", (t) => {
|
||||
// Get the parent domain (remove the first part of the subdomain)
|
||||
const parentSubdomain = subdomain.split(".").slice(1).join(".");
|
||||
|
||||
// Ensure the parent subdomain exists
|
||||
// Ensure the parent subdomain exists in the list of files
|
||||
t.true(
|
||||
files.includes(`${parentSubdomain}.json`),
|
||||
`${file}: Parent domain ${parentSubdomain}.json does not exist`
|
||||
@@ -34,7 +49,7 @@ t("Nested subdomains should not exist if the parent domain has NS records", (t)
|
||||
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
|
||||
// Skip first-level subdomains (i.e., subdomains with only one part like "599.is-cool.dev")
|
||||
// Skip first-level subdomains (i.e., subdomains with only one part like "dibster.is-cool.dev")
|
||||
if (subdomain.split(".").length > 2) {
|
||||
// Get the parent domain (remove the first part of the subdomain)
|
||||
const parentSubdomain = subdomain.split(".").slice(1).join(".");
|
||||
|
||||
Reference in new issue
Block a user