Skip to content

Commit

Permalink
Fixed small issues
Browse files Browse the repository at this point in the history
  • Loading branch information
berrysauce committed Dec 16, 2024
1 parent 24db1d9 commit 07c6934
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions api/src/rdap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ASNInfo, resolveNameserversAndFetchASN } from "./asn";
import { isValidEmail } from "./utils";
import localRdapServicesFile from "./rdap_services.json";

interface RDAPServices {
Expand Down Expand Up @@ -238,6 +239,10 @@ const fetchRdapData = async (rdapService: string, domain: string, featureASNLook
);
if (contactEntry) {
registrantData.contact_uri = contactEntry[3];

if (registrantData.contact_uri && isValidEmail(registrantData.contact_uri) && !registrantData.contact_uri.startsWith("mailto:")) {
registrantData.contact_uri = `mailto:${registrantData.contact_uri}`;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions api/src/rdap_services.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"org": "https://rdap.publicinterestregistry.org/rdap",
"dev": "https://www.registry.google/rdap",
"de": "https://rdap.denic.de"
}
7 changes: 6 additions & 1 deletion api/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ function isValidDomain(domain: string): boolean {
return domainRegex.test(domain);
}

export { isValidDomain };
function isValidEmail(email: string): boolean {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}

export { isValidDomain, isValidEmail };
2 changes: 1 addition & 1 deletion web/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
{result.registrant.organization}<br>
{/if}
{#if result.registrant.contact_uri}
<a href="{result.registrant.contact_uri}" target="_blank" style="color: inherit;">Contact registrant (external link)</a><br>
<a href="{result.registrant.contact_uri}" target="_blank" style="color: inherit;">Contact registrant</a><br>
{/if}

{#if !result.registrant.name && !result.registrant.organization}
Expand Down

0 comments on commit 07c6934

Please sign in to comment.