diff --git a/domains/_github-pages-challenge-clay990.suraj.is-cool.dev.json b/domains/_github-pages-challenge-clay990.suraj.is-cool.dev.json deleted file mode 100644 index c5d411a2..00000000 --- a/domains/_github-pages-challenge-clay990.suraj.is-cool.dev.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "description": "Portfolio project", - "domain": "is-cool.dev", - "subdomain": "_github-pages-challenge-clay990.suraj", - "owner": { - "repo": "https://github.com/Clay990/suraj", - "email": "asuraj991m@gmail.com" - }, - "record": { - "TXT": [ - "53a1f061ccd38386443e96e1948962" - ] - }, - "proxied": false -} diff --git a/domains/_github-pages-challenge-homesteadrd.homesteadrdplaygroup.is-local.org.json b/domains/_github-pages-challenge-homesteadrd.homesteadrdplaygroup.is-local.org.json deleted file mode 100644 index 69f7fed4..00000000 --- a/domains/_github-pages-challenge-homesteadrd.homesteadrdplaygroup.is-local.org.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "Playgroup website", - - "domain": "is-local.org", - "subdomain": "_github-pages-challenge-homesteadrd.homesteadrdplaygroup", - - "owner": { - "repo": "https://github.com/homesteadrd/web", - "email": "homesteadrdplaygroup@gmail.com" - }, - - "record": { - "TXT": ["61fb25de94ffb44246bcda98b23911"] - }, - - "proxied": false -} diff --git a/domains/_github-pages-challenge-jinix6.crystalperson.is-cool.dev.json b/domains/_github-pages-challenge-jinix6.crystalperson.is-cool.dev.json deleted file mode 100644 index aa8096fc..00000000 --- a/domains/_github-pages-challenge-jinix6.crystalperson.is-cool.dev.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "GitHub Pages Verification vrahmanov", - - "domain": "is-cool.dev", - "subdomain": "_github-pages-challenge-jinix6.crystalperson", - - "owner": { - "repo": "https://github.com/jinix6/Craftland", - "email": "nanusahoo05@gmail.com" - }, - - "record": { - "TXT": ["50eb7583c6eeedf6f67806138d93bd"] - }, - - "proxied": false -} diff --git a/domains/_github-pages-challenge-jinix6.crystalperson.is-local.org.json b/domains/_github-pages-challenge-jinix6.crystalperson.is-local.org.json deleted file mode 100644 index 4597b20f..00000000 --- a/domains/_github-pages-challenge-jinix6.crystalperson.is-local.org.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "description": "Verifying custom domain on Github", - - "domain": "is-local.org", - "subdomain": "_github-pages-challenge-jinix6.crystalperson", - - "owner": { - "repo": "https://github.com/jinix6/crystalperson.github.io", - "email": "nanusahoo05@gmail.com" - }, - - "record": { - "TXT": ["50eb7583c6eeedf6f67806138d93bd"] - }, - - "proxied": false -} - - diff --git a/domains/_github-pages-challenge-narmis-e.narmis.is-cool.dev.json b/domains/_github-pages-challenge-narmis-e.narmis.is-cool.dev.json deleted file mode 100644 index d5854099..00000000 --- a/domains/_github-pages-challenge-narmis-e.narmis.is-cool.dev.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "My portfolio hosted on GitHub Pages", - - "domain": "is-cool.dev", - "subdomain": "_github-pages-challenge-Narmis-E.narmis", - - "owner": { - "repo": "https://github.com/narmis-e/portfolio", - "email": "narmisecurb@gmail.com" - }, - - "record": { - "TXT": ["4213f5eb992ffe0d720bc237736a46"] - }, - - "proxied": false -} diff --git a/domains/_github-pages-challenge-openorganizationname.climatehealthei.is-local.org.json b/domains/_github-pages-challenge-openorganizationname.climatehealthei.is-local.org.json deleted file mode 100644 index ade7a288..00000000 --- a/domains/_github-pages-challenge-openorganizationname.climatehealthei.is-local.org.json +++ /dev/null @@ -1,17 +0,0 @@ -{ -"description": "For verifying my domain with github pages", - -"domain": "is-local.org", -"subdomain": "_github-pages-challenge-OpenOrganizationName.climatehealthei", - -"owner": { -"repo": "https://github.com/FizzWizZleDazzle/climatehealthei.github.io", -"email": "arturmisiurev@gmail.com" -}, - -"record": { -"TXT": ["b038216c5480f640390bfcc7168d92"] -}, - -"proxied": false -} diff --git a/domains/_github-pages-challenge-py660.python660.is-loca.org.json b/domains/_github-pages-challenge-py660.python660.is-loca.org.json deleted file mode 100644 index b8438ab7..00000000 --- a/domains/_github-pages-challenge-py660.python660.is-loca.org.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "domain": "is-local.org", - "subdomain": "_github-pages-challenge-py660.python660", - - "owner": { - "repo": "https://github.com/py660/py660", - "email": "py660@irc.cluster.ws" - }, - - "record": { - "TXT": ["9f7bbf7a0a097f15d0b5c76076d9dd"] - } -} diff --git a/domains/_github-pages-challenge-tdevteam.thedevteam.is-cool.dev.json b/domains/_github-pages-challenge-tdevteam.thedevteam.is-cool.dev.json deleted file mode 100644 index 130eb0fc..00000000 --- a/domains/_github-pages-challenge-tdevteam.thedevteam.is-cool.dev.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "To verify this domain for our github org", - - "domain": "is-cool.dev", - "subdomain": "_github-pages-challenge-TDevTeam.thedevteam", - - "owner": { - "repo": "https://github.com/tdevteam", - "email": "TheDevTeam@protonmail.com" - }, - - "record": { - "TXT": ["5e99f2d515b93bdffe4b1e960e1a85"] - }, - - "proxied": false -} diff --git a/domains/_github-pages-challenge-vijay2249.coachbeardjr.localplayer.dev.json b/domains/_github-pages-challenge-vijay2249.coachbeardjr.localplayer.dev.json deleted file mode 100644 index aef7772a..00000000 --- a/domains/_github-pages-challenge-vijay2249.coachbeardjr.localplayer.dev.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "description": "Personal Website", - - "domain": "localplayer.dev", - "subdomain": "_github-pages-challenge-vijay2249.coachbeardjr", - - "owner": { - "email": "coachbeardjr.vvm8p@slmail.me" - }, - - "record": { - "TXT": ["dc0ebd8500ded55870bc8806c70dd5"] - }, - - "proxied": false -} diff --git a/domains/_github-pages-challenge-yesnielx.yesnielx.is-cool.dev.json b/domains/_github-pages-challenge-yesnielx.yesnielx.is-cool.dev.json deleted file mode 100644 index 44206e7b..00000000 --- a/domains/_github-pages-challenge-yesnielx.yesnielx.is-cool.dev.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "GitHub Pages Verification", - - "domain": "is-cool.dev", - "subdomain": "_github-pages-challenge-YesnielX.yesnielx", - - "owner": { - "repo": "https://github.com/YesnielX/yesnielx.github.io", - "email": "yesnielviv2@gmail.com" - }, - - "record": { - "TXT": ["f5fe834daad27fc92c5d3a4b2e0135"] - }, - - "proxied": false - } - \ No newline at end of file diff --git a/domains/amplify.is-a.fullstack.dev.json b/domains/amplify.is-a.fullstack.dev.json deleted file mode 100644 index dfcf101c..00000000 --- a/domains/amplify.is-a.fullstack.dev.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "description": "Amplify's Fullstack Domain", - "domain": "is-a-fullstack.dev", - "subdomain": "amplify", - - "owner": { - "repo": "https://github.com/not-amplify/free-domain/", - "email": "not.amplify@night-x.com" - }, - - "record": { - "NS" : ["summer.ns.cloudflare.com", "terry.ns.cloudflare.com" ] - }, - - "proxied": false -} diff --git a/domains/devil._domainkey.host.mycodelab.is-cool.dev.json b/domains/devil._domainkey.host.mycodelab.is-cool.dev.json index 53773c50..94a130d7 100644 --- a/domains/devil._domainkey.host.mycodelab.is-cool.dev.json +++ b/domains/devil._domainkey.host.mycodelab.is-cool.dev.json @@ -1,16 +1,14 @@ { - "description": "mycodelab mail, this is for temporary so i can transfer my mails to another account", - - "domain": "is-cool.dev", - "subdomain": "devil._domainkey.host.mycodelab", - - "owner": { - "repo": "https://github.com/ShadowGaming100/register" - }, - - "record": { - "TXT": ["v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRR//eLOhnpXyeRihLl1AnM/Ysj4cFG6873HAzsL4ubge6mmzmwGtb9xWQiY79kAfpQBv+CFnirFvMdZQldcJDMCbcrbeEBMaNxOi5udf1lmLH/6M1VMnu6Y2VCCoBSP7XhHqOVWDkThi1ROFB6mKwZQkypo+fz7tE6xwgVkJBCQIDAQAB;"] - }, - - "proxied": false + "description": "mycodelab mail, this is for temporary so i can transfer my mails to another account", + "domain": "is-cool.dev", + "subdomain": "devil._domainkey.host.mycodelab", + "owner": { + "repo": "https://github.com/ShadowGaming100/register" + }, + "record": { + "TXT": [ + "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRR//eLOhnpXyeRihLl1AnM/Ysj4cFG6873HAzsL4ubge6mmzmwGtb9xWQiY79kAfpQBv+CFnirFvMdZQldcJDMCbcrbeEBMaNxOi5udf1lmLH/6M1VMnu6Y2VCCoBSP7XhHqOVWDkThi1ROFB6mKwZQkypo+fz7tE6xwgVkJBCQIDAQAB;" + ] + }, + "proxied": false } diff --git a/domains/potpry.is-cool.dev..json b/domains/potpry.is-cool.dev..json deleted file mode 100644 index b89fcbba..00000000 --- a/domains/potpry.is-cool.dev..json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "description": "Personal Cloud Study", - - "domain": "is-cool.dev", - "subdomain": "potpry", - - "owner": { - "email": "potprytest+open-domains@gmail.com" - }, - - "record": { - "A": ["158.247.216.53"] - }, - - "proxied": false -} diff --git a/domains/privacy.isdev.localplayer.dev.json b/domains/privacy.isdev.localplayer.dev.json deleted file mode 100644 index 7b136ed5..00000000 --- a/domains/privacy.isdev.localplayer.dev.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "website", - - "domain": "localplayer.dev", - "subdomain": "privacy.isdev", - - "owner": { - "repo": "https://github.com/is-a-dev/register", - "email": "andrew@win11react.com" - }, - - "record": { - "MX": ["mx.sendgrid.net"] - }, - - "proxied": false -} diff --git a/tests/domains.test.js b/tests/domains.test.js index 9d592f4f..69fd3a4f 100644 --- a/tests/domains.test.js +++ b/tests/domains.test.js @@ -5,16 +5,17 @@ const path = require("path"); const domainsPath = path.resolve("domains"); const files = fs.readdirSync(domainsPath); -/** - * Helper function to determine if a subdomain is a root domain. - * A root domain is assumed to be exactly two parts (e.g., "is-cool.dev"). - */ -function isRootDomain(domain) { - return domain.split(".").length === 2; -} +// Extract valid root domains dynamically from the files +const validRootDomains = Array.from( + new Set( + files + .map((file) => file.split(".").slice(-2).join(".")) + .filter((domain) => domain.endsWith(".dev") || domain.endsWith(".org")) + ) +); -t("Nested subdomains should not exist without a parent subdomain", (t) => { - const issues = []; +t("Nested subdomains should not exist without a valid parent domain", (t) => { + const invalidFiles = []; files.forEach((file) => { // Skip directories and process only .json files @@ -25,28 +26,27 @@ t("Nested subdomains should not exist without a parent subdomain", (t) => { const subdomain = file.replace(/\.json$/, ""); - if (subdomain.split(".").length > 2) { - // Get parent domain by removing the leftmost part - const parentSubdomain = subdomain.split(".").slice(1).join("."); + // Find the first-level parent subdomain + const parentSubdomainParts = subdomain.split("."); + const rootDomain = parentSubdomainParts.slice(-2).join("."); + const firstLevelParent = `${parentSubdomainParts.slice(-3, -2)[0]}.${rootDomain}`; - // Skip check if the parent subdomain is a root domain - if (isRootDomain(parentSubdomain)) { - return; - } - - // Check if the parent subdomain exists - if (!files.includes(`${parentSubdomain}.json`)) { - issues.push(`${file}: Parent subdomain ${parentSubdomain}.json does not exist`); - } + if ( + parentSubdomainParts.length > 2 && // Must have at least one subdomain + validRootDomains.includes(rootDomain) && // Must belong to a valid root domain + !files.includes(`${firstLevelParent}.json`) // Parent must exist + ) { + invalidFiles.push(`${file}: Parent domain ${firstLevelParent}.json does not exist`); } }); - // Report all issues at once - t.deepEqual(issues, [], `Found issues:\n${issues.join("\n")}`); + // Fail the test if there are invalid files + invalidFiles.forEach((message) => t.fail(message)); + t.pass(); }); -t("Nested subdomains should not exist if the parent subdomain has NS records", (t) => { - const issues = []; +t("Nested subdomains should not exist if the parent domain has NS records", (t) => { + const invalidFiles = []; files.forEach((file) => { // Skip directories and process only .json files @@ -57,30 +57,25 @@ t("Nested subdomains should not exist if the parent subdomain has NS records", ( const subdomain = file.replace(/\.json$/, ""); - if (subdomain.split(".").length > 2) { - // Get parent domain by removing the leftmost part - const parentSubdomain = subdomain.split(".").slice(1).join("."); - const parentFilePath = path.join(domainsPath, `${parentSubdomain}.json`); + // Find the first-level parent subdomain + const parentSubdomainParts = subdomain.split("."); + const rootDomain = parentSubdomainParts.slice(-2).join("."); + const firstLevelParent = `${parentSubdomainParts.slice(-3, -2)[0]}.${rootDomain}`; + const parentFilePath = path.join(domainsPath, `${firstLevelParent}.json`); - // Skip check if the parent subdomain is a root domain - if (isRootDomain(parentSubdomain)) { - return; - } - - // Check if the parent file exists before attempting to read it + if (parentSubdomainParts.length > 2 && validRootDomains.includes(rootDomain)) { if (fs.existsSync(parentFilePath)) { const parentDomain = fs.readJsonSync(parentFilePath); - - // Check if the parent has NS records - if (parentDomain.record.NS !== undefined) { - issues.push(`${file}: Parent subdomain ${parentSubdomain} has NS records`); + if (parentDomain.record?.NS) { + invalidFiles.push(`${file}: Parent domain ${firstLevelParent} has NS records`); } } else { - issues.push(`${file}: Parent subdomain ${parentSubdomain}.json file does not exist`); + invalidFiles.push(`${file}: Parent domain ${firstLevelParent}.json does not exist`); } } }); - // Report all issues at once - t.deepEqual(issues, [], `Found issues:\n${issues.join("\n")}`); + // Fail the test if there are invalid files + invalidFiles.forEach((message) => t.fail(message)); + t.pass(); });