Add support for custom fetch function and/or IANA bootstrap data (#21)

This commit is contained in:
2025-10-30 19:07:12 -04:00
committed by GitHub
parent acae007a4a
commit 619185b5d6
22 changed files with 1346 additions and 163 deletions
+1
View File
@@ -30,6 +30,7 @@ describe("WHOIS coalescing", () => {
expect(chain.length).toBe(1);
const [first] = chain;
if (!first) throw new Error("Expected first record");
const base = normalizeWhois(
"gitpod.io",
"io",
+2 -1
View File
@@ -11,7 +11,8 @@ Changed: 2020-01-02
`;
const rec = normalizeWhois("example.de", "de", text, "whois.denic.de");
expect(rec.nameservers && rec.nameservers.length === 2).toBe(true);
expect(rec.nameservers?.[0].host).toBe("ns1.example.net");
expect(rec.nameservers).toBeDefined();
expect(rec.nameservers?.[0]?.host).toBe("ns1.example.net");
});
test("WHOIS .uk Nominet style", () => {
+8 -3
View File
@@ -155,7 +155,12 @@ export function normalizeWhois(
map.eppstatus || // .fr
[];
const statuses = statusLines.length
? statusLines.map((line) => ({ status: line.split(/\s+/)[0], raw: line }))
? statusLines
.map((line) => {
const status = line.split(/\s+/)[0];
return status ? { status, raw: line } : null;
})
.filter((s): s is { status: string; raw: string } => s !== null)
: undefined;
// Nameservers: also appear as "nserver" on some ccTLDs (.de, .ru) and as "name server"
@@ -219,8 +224,8 @@ export function normalizeWhois(
: undefined;
// Simple lock derivation from statuses
const transferLock = !!statuses?.some((s) =>
/transferprohibited/i.test(s.status),
const transferLock = !!statuses?.some(
(s) => s.status && /transferprohibited/i.test(s.status),
);
const record: DomainRecord = {
+1 -1
View File
@@ -40,6 +40,6 @@ describe("WHOIS referral contradiction handling", () => {
expect(Array.isArray(chain)).toBe(true);
// Mocked registrar is contradictory, so chain should contain only the TLD response
expect(chain.length).toBe(1);
expect(chain[0].serverQueried).toBe("whois.nic.io");
expect(chain[0]?.serverQueried).toBe("whois.nic.io");
});
});