From f613cabe1bc1abd6424573b035d1f2e9f5906678 Mon Sep 17 00:00:00 2001 From: William Harrison <87287585+wdhdev@users.noreply.github.com> Date: Thu, 13 Feb 2025 17:08:01 +0800 Subject: [PATCH] revert untested changes This partially reverts commit 6f5402a07247850fa7a08d0c2b74e2fe108195a2. --- dnsconfig.js | 5 ----- tests/json.test.js | 5 +++-- tests/records.test.js | 13 +++++++++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dnsconfig.js b/dnsconfig.js index 636e74297..3cd55b011 100644 --- a/dnsconfig.js +++ b/dnsconfig.js @@ -103,11 +103,6 @@ for (var subdomain in domains) { if (domainData.record.URL) { records.push(A(subdomainName, IP("192.0.2.1"), CF_PROXY_ON)); } - - // Handle redirects - if (domainData.redirect_config && !domainData.record.A && !domainData.record.AAAA && !domainData.record.CNAME) { - records.push(A(subdomainName, IP("192.0.2.1"), CF_PROXY_ON)); - } } var options = { diff --git a/tests/json.test.js b/tests/json.test.js index 9e5a95cf7..e6f77d5df 100644 --- a/tests/json.test.js +++ b/tests/json.test.js @@ -165,10 +165,11 @@ t("All files should have valid required and optional fields", (t) => { // Validate email format if (data.owner.email) { t.regex(data.owner.email, emailRegex, `${file}: Owner email should be a valid email address`); + t.true(!data.owner.email.endsWith("@users.noreply.github.com"), `${file}: Owner email should not be a GitHub no-reply email`); } - // Ensure 'record' field is not empty unless using redirect_config - t.true(Object.keys(data.record).length > 0 || data.redirect_config.custom_paths, `${file}: Missing DNS records`); + // Ensure 'record' field is not empty + t.true(Object.keys(data.record).length > 0, `${file}: Missing DNS records`); }); }); diff --git a/tests/records.test.js b/tests/records.test.js index 255b482fc..223971308 100644 --- a/tests/records.test.js +++ b/tests/records.test.js @@ -215,8 +215,8 @@ function validateRecordValues(t, data, file) { `${urlMessage} must start with a slash, contain only alphanumeric characters, hyphens, underscores, periods, and slashes, and cannot end with a slash at index ${idx}` ); t.true( - customPath.length >= 1 && customPath.length <= 255, - `${urlMessage} should be 1-255 characters long at index ${idx}` + customPath.length >= 2 && customPath.length <= 255, + `${urlMessage} should be 2-255 characters long at index ${idx}` ); // Validate the redirect URL @@ -266,6 +266,15 @@ t("All files should have valid record types", (t) => { `${file}: URL records cannot be combined with A, AAAA, or CNAME records` ); } + if (data.redirect_config) { + t.true( + recordKeys.includes("URL") || data.proxied, + `${file}: Redirect config must be combined with a URL record or the domain must be proxied` + ); + if (data.redirect_config.redirect_paths) { + t.true(recordKeys.includes("URL"), `${file}: redirect_config.redirect_paths requires a URL record`); + } + } validateRecordValues(t, data, file); });