fix: handle multi-level public suffixes in RDAP lookup (#6752)
This commit is contained in:
parent
324404f780
commit
81ae0af7e1
@ -30,10 +30,13 @@ async function getRdapServer(tld) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const service of rdapList["services"]) {
|
const services = rdapList["services"] ?? [];
|
||||||
const [tlds, urls] = service;
|
const rootTld = tld?.split(".").pop();
|
||||||
if (tlds.includes(tld)) {
|
if (rootTld) {
|
||||||
return urls[0];
|
for (const [tlds, urls] of services) {
|
||||||
|
if (tlds.includes(rootTld)) {
|
||||||
|
return urls[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.debug("rdap", `No RDAP server found for TLD ${tld}`);
|
log.debug("rdap", `No RDAP server found for TLD ${tld}`);
|
||||||
@ -173,16 +176,18 @@ class DomainExpiry extends BeanModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const rdap = await getRdapServer(tld.publicSuffix);
|
const publicSuffix = tld.publicSuffix;
|
||||||
|
const rootTld = publicSuffix.split(".").pop();
|
||||||
|
const rdap = await getRdapServer(publicSuffix);
|
||||||
if (!rdap) {
|
if (!rdap) {
|
||||||
throw new TranslatableError("domain_expiry_unsupported_unsupported_tld_no_rdap_endpoint", {
|
throw new TranslatableError("domain_expiry_unsupported_unsupported_tld_no_rdap_endpoint", {
|
||||||
publicSuffix: tld.publicSuffix,
|
publicSuffix,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
domain: tld.domain,
|
domain: tld.domain,
|
||||||
tld: tld.publicSuffix,
|
tld: rootTld,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -157,6 +157,17 @@ describe("Domain Expiry", () => {
|
|||||||
assert.strictEqual(supportInfo.tld, "com");
|
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, "br");
|
||||||
|
});
|
||||||
|
|
||||||
test("handles complex subdomain correctly", async () => {
|
test("handles complex subdomain correctly", async () => {
|
||||||
const monitor = {
|
const monitor = {
|
||||||
type: "http",
|
type: "http",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user