Handle multi-level TLDs in RDAP lookup
This commit is contained in:
parent
f470b01168
commit
449bb07e6b
@ -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}`);
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user