Skip to content

Commit cc409a2

Browse files
committed
Refactor registration section to enhance RDAP server link display and remove unused formatting function
1 parent b300502 commit cc409a2

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

components/domain/sections/registration-section.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,25 @@ export function RegistrationSection({
7777
<span>
7878
Verified by{" "}
7979
<span className="font-medium">
80-
{formatRegistrationSourceHost(data) ??
81-
(data.source === "rdap" ? "RDAP" : "WHOIS")}
80+
{data.source === "rdap" &&
81+
Array.isArray(data.rdapServers) &&
82+
data.rdapServers.length > 0 ? (
83+
<a
84+
href={
85+
data.rdapServers[data.rdapServers.length - 1] ??
86+
"#"
87+
}
88+
target="_blank"
89+
rel="noopener"
90+
className="underline underline-offset-2"
91+
>
92+
{extractHostnameFromUrlish(
93+
data.rdapServers[data.rdapServers.length - 1],
94+
) ?? "RDAP"}
95+
</a>
96+
) : (
97+
(data.whoisServer ?? "WHOIS")
98+
)}
8299
</span>
83100
</span>
84101
<a
@@ -189,15 +206,3 @@ export function extractRegistrantView(
189206
const state = (registrant.state || "").toString() || undefined;
190207
return { organization, country, state };
191208
}
192-
193-
export function formatRegistrationSourceHost(
194-
data: Registration,
195-
): string | undefined {
196-
if (data.source === "rdap") {
197-
const servers = data.rdapServers;
198-
const last =
199-
servers && servers.length > 0 ? servers[servers.length - 1] : undefined;
200-
return extractHostnameFromUrlish(last);
201-
}
202-
return extractHostnameFromUrlish(data.whoisServer) ?? data.whoisServer;
203-
}

0 commit comments

Comments
 (0)