[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2026-01-14 16:14:21 +00:00 committed by GitHub
parent 6f3727a548
commit e5cb1c19c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 13 deletions

View File

@ -167,9 +167,9 @@ class DomainExpiry extends BeanModel {
// 1. Validation Checks (Must pass these first) // 1. Validation Checks (Must pass these first)
// Avoid logging for incomplete/invalid input while editing monitors. // Avoid logging for incomplete/invalid input while editing monitors.
if (!tld.domain && !tld.hostname) { if (!tld.domain && !tld.hostname) {
// If neither domain nor hostname is present, it's invalid // If neither domain nor hostname is present, it's invalid
// Fallback to basic hostname check if tldts fails completely // Fallback to basic hostname check if tldts fails completely
throw new TranslatableError("domain_expiry_unsupported_invalid_domain", { hostname: target }); throw new TranslatableError("domain_expiry_unsupported_invalid_domain", { hostname: target });
} }
// Check for IP addresses // Check for IP addresses
@ -183,11 +183,11 @@ class DomainExpiry extends BeanModel {
if (!tld.isIcann) { if (!tld.isIcann) {
// But we still want to ensure it looks like a domain (has at least one dot) // But we still want to ensure it looks like a domain (has at least one dot)
if (!tld.hostname || !tld.hostname.includes(".")) { if (!tld.hostname || !tld.hostname.includes(".")) {
// It's a single word like "localhost" or "server" - technically valid for local DNS, // It's a single word like "localhost" or "server" - technically valid for local DNS,
// but might fail "domain part" tests if they expect a TLD. // but might fail "domain part" tests if they expect a TLD.
// For now, let's treat single words as valid local domains if they aren't IPs. // For now, let's treat single words as valid local domains if they aren't IPs.
} }
return { return {
domain: tld.domain || tld.hostname, domain: tld.domain || tld.hostname,
tld: tld.publicSuffix || tld.hostname.split(".").pop(), tld: tld.publicSuffix || tld.hostname.split(".").pop(),
@ -339,4 +339,4 @@ class DomainExpiry extends BeanModel {
} }
} }
module.exports = DomainExpiry; module.exports = DomainExpiry;

View File

@ -15,7 +15,6 @@ dayjs.extend(require("dayjs/plugin/utc"));
const testDb = new TestDB(); const testDb = new TestDB();
describe("Domain Expiry", () => { describe("Domain Expiry", () => {
before(async () => { before(async () => {
await testDb.create(); await testDb.create();
Notification.init(); Notification.init();
@ -28,11 +27,11 @@ describe("Domain Expiry", () => {
test("getExpiryDate() returns correct expiry date for .wiki domain with no A record", async () => { test("getExpiryDate() returns correct expiry date for .wiki domain with no A record", async () => {
const d = DomainExpiry.createByName("google.wiki"); const d = DomainExpiry.createByName("google.wiki");
// Note: This relies on external RDAP, so check if it resolved. // Note: This relies on external RDAP, so check if it resolved.
// If network is blocked, this might fail, but logic implies it should work. // If network is blocked, this might fail, but logic implies it should work.
const date = await d.getExpiryDate(); const date = await d.getExpiryDate();
if (date) { if (date) {
assert.deepEqual(date, new Date("2026-11-26T23:59:59.000Z")); assert.deepEqual(date, new Date("2026-11-26T23:59:59.000Z"));
} }
}); });
@ -235,7 +234,7 @@ describe("Domain Expiry", () => {
const domain = await DomainExpiry.findByName("google.com"); const domain = await DomainExpiry.findByName("google.com");
// Check if lastCheck was updated recently (within 60 seconds) // Check if lastCheck was updated recently (within 60 seconds)
if (domain && domain.lastCheck) { if (domain && domain.lastCheck) {
assert.ok(dayjs.utc().diff(dayjs.utc(domain.lastCheck), "second") < 60); assert.ok(dayjs.utc().diff(dayjs.utc(domain.lastCheck), "second") < 60);
} }
}); });
@ -364,4 +363,4 @@ describe("Domain Expiry", () => {
mock.restoreAll(); mock.restoreAll();
} }
}); });
}); });