mirror of
https://github.com/jakejarvis/rdapper.git
synced 2026-10-26 08:26:22 -04:00
fix: read WHOIS keys padded with dots
.fi writes every key as "created............: 15.8.2017" and .no several, and the padding stayed in the key, so no field matched: .fi lookups failed as "unparseable" and .no lost its DNSSEC flag. Strip trailing runs of dots from keys. Across the saved corpus only norid.no's DNSSEC changed; .fi now parses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2 files changed
+32
-1
No files matched your search
+6
-1
@@ -51,7 +51,12 @@ export function parseKeyValueLines(text: string): Record<string, string[]> {
|
||||
// Colon form: Key: value
|
||||
const idx = line.indexOf(":");
|
||||
if (idx !== -1) {
|
||||
const key = line.slice(0, idx).trim().toLowerCase();
|
||||
// Some registries pad keys with dots: "created............: 15.8.2017" (.fi, .no)
|
||||
const key = line
|
||||
.slice(0, idx)
|
||||
.replace(/\.{2,}\s*$/, "")
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
const value = line.slice(idx + 1).trim();
|
||||
if (!key) {
|
||||
lastKey = undefined;
|
||||
|
||||
@@ -416,3 +416,29 @@ test.each([
|
||||
);
|
||||
expect(rec.dnssec?.enabled).toBe(enabled);
|
||||
});
|
||||
|
||||
test("WHOIS keys padded with dots (.fi)", () => {
|
||||
// Excerpt of whois.fi for traficom.fi
|
||||
const text = `
|
||||
domain.............: traficom.fi
|
||||
status.............: Registered
|
||||
created............: 15.8.2017 15:02:40
|
||||
expires............: 15.8.2029 15:02:40
|
||||
modified...........: 23.5.2026 18:17:05
|
||||
|
||||
Nameservers
|
||||
nserver............: ns1.z.fi [OK]
|
||||
nserver............: ns2.z.fi [OK]
|
||||
|
||||
DNSSEC
|
||||
dnssec.............: signed delegation
|
||||
`;
|
||||
const rec = normalizeWhois("traficom.fi", "fi", text, "whois.fi");
|
||||
expect(rec).toMatchObject({
|
||||
creationDate: "2017-08-15T15:02:40Z",
|
||||
expirationDate: "2029-08-15T15:02:40Z",
|
||||
updatedDate: "2026-05-23T18:17:05Z",
|
||||
nameservers: [{ host: "ns1.z.fi" }, { host: "ns2.z.fi" }],
|
||||
dnssec: { enabled: true },
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user