Prefer TLD WHOIS over contradictory registrar referral; revert heuristic override and add referral test\n\n- Keep TLD response when registrar says ‘not found’\n- Revert WHOIS isRegistered to simple availability check\n- Add referral contradiction unit test for .io scenario\n- All tests passing

This commit is contained in:
2025-10-14 13:24:51 -04:00
parent c3a68639b6
commit 4e9b99a25f
3 changed files with 44 additions and 1 deletions
+9 -1
View File
@@ -1,3 +1,4 @@
import { isWhoisAvailable } from "../lib/domain";
import type { LookupOptions } from "../types";
import type { WhoisQueryResult } from "./client";
import { whoisQuery } from "./client";
@@ -28,7 +29,14 @@ export async function followWhoisReferrals(
visited.add(normalized);
try {
const res = await whoisQuery(next, domain, opts);
current = res; // adopt the newer, more specific result
// Prefer authoritative TLD response when registrar contradicts availability
const registeredBefore = !isWhoisAvailable(current.text);
const registeredAfter = !isWhoisAvailable(res.text);
if (registeredBefore && !registeredAfter) {
// Registrar claims availability but TLD shows registered: keep TLD
break;
}
current = res; // adopt registrar when it does not downgrade registration
} catch {
// If referral server fails, stop following and keep the last good response
break;