mirror of
https://github.com/jakejarvis/rdapper.git
synced 2026-09-23 01:25:31 -04:00
Enhance date parsing in WHOIS and add tests for registrar expiration dates
Updated the `toISO` function to handle various timezone formats in WHOIS date strings. Added tests to verify parsing of registrar registration expiration dates and EDUCAUSE format dates in the normalization process. This improves the accuracy of date handling in WHOIS responses.
This commit is contained in:
@@ -96,6 +96,49 @@ DNSSEC: unsigned
|
||||
expect(rec.nameservers && rec.nameservers.length === 2).toBe(true);
|
||||
});
|
||||
|
||||
test("WHOIS registrar response with Registrar Registration Expiration Date", () => {
|
||||
const text = `
|
||||
Domain Name: EXAMPLE.US
|
||||
Registrar WHOIS Server: whois.registrar.test
|
||||
Registrar URL: http://www.registrar.test
|
||||
Updated Date: 2025-03-23T10:53:03+0000
|
||||
Creation Date: 2020-04-24T15:03:39+0000
|
||||
Registrar Registration Expiration Date: 2027-04-23T00:00:00+0000
|
||||
Registrar: Registrar LLC
|
||||
`;
|
||||
const rec = normalizeWhois(
|
||||
"example.us",
|
||||
"us",
|
||||
text,
|
||||
"whois.registrar.test",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
expect(Boolean(rec.expirationDate)).toBe(true);
|
||||
expect(rec.expirationDate).toBe("2027-04-23T00:00:00Z");
|
||||
});
|
||||
|
||||
test("WHOIS .edu EDUCAUSE format", () => {
|
||||
const text = `
|
||||
This Registry database contains ONLY .EDU domains.
|
||||
|
||||
Domain Name: TUFTS.EDU
|
||||
|
||||
Domain record activated: 22-Jun-1987
|
||||
Domain record last updated: 02-Jul-2025
|
||||
Domain expires: 31-Jul-2026
|
||||
`;
|
||||
const rec = normalizeWhois(
|
||||
"tufts.edu",
|
||||
"edu",
|
||||
text,
|
||||
"whois.educause.edu",
|
||||
"2025-01-01T00:00:00Z",
|
||||
);
|
||||
expect(rec.creationDate).toBe("1987-06-22T00:00:00Z");
|
||||
expect(rec.updatedDate).toBe("2025-07-02T00:00:00Z");
|
||||
expect(rec.expirationDate).toBe("2026-07-31T00:00:00Z");
|
||||
});
|
||||
|
||||
test("Privacy redacted WHOIS normalizes without contacts", () => {
|
||||
const text = `
|
||||
Domain Name: EXAMPLE.COM
|
||||
|
||||
@@ -31,17 +31,29 @@ export function normalizeWhois(
|
||||
"domain create date",
|
||||
"created",
|
||||
"registered",
|
||||
// EDUCAUSE (.edu)
|
||||
"domain record activated",
|
||||
]);
|
||||
const updatedDate = anyValue(map, [
|
||||
"updated date",
|
||||
"last updated",
|
||||
"last modified",
|
||||
"modified",
|
||||
// EDUCAUSE (.edu)
|
||||
"domain record last updated",
|
||||
]);
|
||||
const expirationDate = anyValue(map, [
|
||||
"registry expiry date",
|
||||
"registry expiration date",
|
||||
"expiry date",
|
||||
"expiration date",
|
||||
// Registrar-side synonyms commonly seen after referrals
|
||||
"registrar registration expiration date",
|
||||
"registrar registration expiry date",
|
||||
"registrar expiration date",
|
||||
"registrar expiry date",
|
||||
// EDUCAUSE (.edu)
|
||||
"domain expires",
|
||||
"paid-till",
|
||||
"expires on",
|
||||
"renewal date",
|
||||
|
||||
Reference in New Issue
Block a user