fix: suppress domain expiry warnings for local domains (#6682)

This commit is contained in:
Ian Macabulos 2026-01-14 23:26:50 +08:00
parent 31d2417dde
commit d31ee4b7f0

View File

@ -15,6 +15,20 @@ const cachedFetch = process.env.NODE_ENV
})
: fetch;
// List of TLDs that do not support RDAP/public expiry dates.
// We ignore these to prevent log warnings.
const IGNORED_TLDS = [
"local",
"internal",
"lan",
"home",
"corp",
"test",
"example",
"invalid",
"localhost"
];
/**
* Find the RDAP server for a given TLD
* @param {string} tld TLD
@ -47,6 +61,12 @@ async function getRdapServer(tld) {
*/
async function getRdapDomainExpiryDate(domain) {
const tld = DomainExpiry.parseTld(domain).publicSuffix;
// Skip ignored TLDs silently
if (tld && IGNORED_TLDS.includes(tld)) {
return null;
}
const rdapServer = await getRdapServer(tld);
if (rdapServer === null) {
log.warn("rdap", `No RDAP server found, TLD ${tld} not supported.`);
@ -174,6 +194,14 @@ class DomainExpiry extends BeanModel {
throw new TranslatableError("domain_expiry_public_suffix_too_short", { publicSuffix: tld.publicSuffix });
}
// Allow ignored TLDs to bypass RDAP check and save successfully
if (IGNORED_TLDS.includes(tld.publicSuffix)) {
return {
domain: tld.domain,
tld: tld.publicSuffix,
};
}
const rdap = await getRdapServer(tld.publicSuffix);
if (!rdap) {
throw new TranslatableError("domain_expiry_unsupported_unsupported_tld_no_rdap_endpoint", {
@ -308,4 +336,4 @@ class DomainExpiry extends BeanModel {
}
}
module.exports = DomainExpiry;
module.exports = DomainExpiry;