MCPcopy
hub / github.com/lissy93/web-check / toIso

Function toIso

api/whois.js:33–41  ·  view source on GitHub ↗
(raw)

Source from the content-addressed store, hash-verified

31
32// Convert a date string to ISO 8601 when parseable, otherwise return the raw value
33const toIso = (raw) => {
34 if (!raw || typeof raw !== 'string') return raw;
35 const trimmed = raw.trim().replace(/\s*#.*$/, '');
36 const t = Date.parse(trimmed);
37 if (!Number.isNaN(t)) return new Date(t).toISOString();
38 const m = trimmed.match(/^(\d{4})(\d{2})(\d{2})$/);
39 if (m) return new Date(`${m[1]}-${m[2]}-${m[3]}T00:00:00Z`).toISOString();
40 return raw;
41};
42
43// Reduce a hostname to its registrable domain so registry WHOIS lookups succeed
44const baseDomain = (host) => psl.parse(host)?.domain || host;

Callers 1

whoisHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected