Handle multi-level TLDs in RDAP lookup

This commit is contained in:
Joseph Adams 2026-01-16 19:12:12 +01:00
parent f470b01168
commit 449bb07e6b
2 changed files with 28 additions and 4 deletions

View File

@ -30,10 +30,23 @@ async function getRdapServer(tld) {
return null;
}
for (const service of rdapList["services"]) {
const [tlds, urls] = service;
if (tlds.includes(tld)) {
return urls[0];
const candidates = [];
if (tld) {
candidates.push(tld);
if (tld.includes(".")) {
const root = tld.split(".").pop();
if (root && root !== tld) {
candidates.push(root);
}
}
}
for (const candidate of candidates) {
for (const service of rdapList["services"]) {
const [tlds, urls] = service;
if (tlds.includes(candidate)) {
return urls[0];
}
}
}
log.debug("rdap", `No RDAP server found for TLD ${tld}`);

View File

@ -157,6 +157,17 @@ describe("Domain Expiry", () => {
assert.strictEqual(supportInfo.tld, "com");
});
test("supports multi-level public suffix via RDAP fallback (e.g. com.br)", async () => {
const monitor = {
type: "http",
url: "https://record.com.br",
domainExpiryNotification: true,
};
const supportInfo = await DomainExpiry.checkSupport(monitor);
assert.strictEqual(supportInfo.domain, "record.com.br");
assert.strictEqual(supportInfo.tld, "com.br");
});
test("handles complex subdomain correctly", async () => {
const monitor = {
type: "http",