1
mirror of https://github.com/jakejarvis/hoot.git synced 2025-10-18 20:14:25 -04:00

Refactor registration section to enhance RDAP server link display and remove unused formatting function

This commit is contained in:
2025-10-10 11:29:42 -04:00
parent b300502c9a
commit cc409a2cef

View File

@@ -77,8 +77,25 @@ export function RegistrationSection({
<span>
Verified by{" "}
<span className="font-medium">
{formatRegistrationSourceHost(data) ??
(data.source === "rdap" ? "RDAP" : "WHOIS")}
{data.source === "rdap" &&
Array.isArray(data.rdapServers) &&
data.rdapServers.length > 0 ? (
<a
href={
data.rdapServers[data.rdapServers.length - 1] ??
"#"
}
target="_blank"
rel="noopener"
className="underline underline-offset-2"
>
{extractHostnameFromUrlish(
data.rdapServers[data.rdapServers.length - 1],
) ?? "RDAP"}
</a>
) : (
(data.whoisServer ?? "WHOIS")
)}
</span>
</span>
<a
@@ -189,15 +206,3 @@ export function extractRegistrantView(
const state = (registrant.state || "").toString() || undefined;
return { organization, country, state };
}
export function formatRegistrationSourceHost(
data: Registration,
): string | undefined {
if (data.source === "rdap") {
const servers = data.rdapServers;
const last =
servers && servers.length > 0 ? servers[servers.length - 1] : undefined;
return extractHostnameFromUrlish(last);
}
return extractHostnameFromUrlish(data.whoisServer) ?? data.whoisServer;
}