© 2024 Nikola Nenovski. All right reserved.
© {getCurrentYear()} Nikola Nenovski. All rights reserved.
| undefined;
loading: boolean;
}> = ({ content, loading }) => {
+ const whoisRows = useMemo(() => {
+ if (!content?.result) return [];
+
+ const {
+ registrar,
+ name_servers,
+ creation_date,
+ expiration_date,
+ updated_date,
+ status,
+ dnssec,
+ } = content.result;
+
+ const transformedWhoisObj = {
+ Registrar: registrar,
+ Name_Servers: Array.isArray(name_servers)
+ ? name_servers
+ : name_servers.substring(0, name_servers.indexOf(' ')),
+ Registered_On: new Date(creation_date).toLocaleDateString(),
+ Expires_On: `${new Date(expiration_date).toLocaleDateString()} (${getDays(
+ expiration_date
+ )} days)`,
+ Last_updated_On: new Date(updated_date).toLocaleDateString(),
+ Status: Array.isArray(status)
+ ? status.map((s: string) => s.substring(0, s.indexOf(' ')))
+ : status.substring(0, status.indexOf(' ')),
+ DNSSEC: dnssec,
+ };
+
+ return Object.entries(transformedWhoisObj).map(
+ ([key, value]: [string, string | string[]]) => ({
+ label: key.replace(/_/g, ' '),
+ value,
+ })
+ );
+ }, [content]);
+
return (
{loading ? (
@@ -13,71 +50,27 @@ const WhoisTable: React.FC<{
) : !content ? (
-
Data could not be fetched.
+
Whois data could not be fetched.
) : (
-
- | Registrar |
- {content?.result!.registrar} |
-
-
- | Name Servers |
-
-
- {content?.result!.name_servers.map(
- (ns: string, idx: number) => (
- - {ns}
- )
+ {whoisRows.map(row => (
+
+ | {row.label} |
+
+ {Array.isArray(row.value) ? (
+
+ {row.value.map((r: string, idx: number) => (
+ - {r}
+ ))}
+
+ ) : (
+ row.value
)}
-
- |
-
-
- | Registered On |
-
- {new Date(content?.result!.creation_date).toLocaleDateString()}
- |
-
-
- | Expires On |
-
- {new Date(
- content?.result!.expiration_date
- ).toLocaleDateString()}{' '}
- ({getDays(content?.result!.expiration_date)} days)
- |
-
-
- | Last updated On |
-
- {new Date(content?.result!.updated_date).toLocaleDateString()}
- |
-
-
- | Status |
-
- {typeof content?.result!.status === 'string' ? (
-
- {content?.result!.status.substring(
- 0,
- content?.result!.status.indexOf(' ')
- )}
-
- ) : (
-
- {content?.result!.status.map((row: string, idx: number) => (
- - {row.substring(0, row.indexOf(' '))}
- ))}
-
- )}
- |
-
-
- | DNSSEC |
- {content?.result!.dnssec} |
-
+ |
+
+ ))}
)}
diff --git a/src/services/cdnCheck.service.ts b/src/services/cdnCheck.service.ts
index cb1d140..265d6c4 100644
--- a/src/services/cdnCheck.service.ts
+++ b/src/services/cdnCheck.service.ts
@@ -14,5 +14,6 @@ export const isCdnActive = async (domain: string) => {
return response.data.data;
} catch (error) {
console.error(error);
+ return {};
}
};
diff --git a/src/services/http/whois.get.endpoints.http b/src/services/http/whois.get.endpoints.http
index f6fb4e8..fc57081 100644
--- a/src/services/http/whois.get.endpoints.http
+++ b/src/services/http/whois.get.endpoints.http
@@ -18,5 +18,5 @@ GET {{WHOIS_API_URL}}
# @import ./variables.http
GET {{WHOIS_API_URL}}
- ?domain=nikolanenovski.com
- apikey:{{WHOIS_API_KEY}}
\ No newline at end of file
+ ?domain=random.co.uk
+ apikey:{{WHOIS_API_KEY}}
diff --git a/src/services/wpCheck.service.ts b/src/services/wpCheck.service.ts
index 08c2ef9..e3df0bf 100644
--- a/src/services/wpCheck.service.ts
+++ b/src/services/wpCheck.service.ts
@@ -14,5 +14,6 @@ export const isWordpressInstalled = async (domain: string) => {
return response.data.data;
} catch (error) {
console.error(error);
+ return { wordpressInstalled: false };
}
};
diff --git a/src/views/Results.tsx b/src/views/Results.tsx
index 8ff7d64..e6b76cc 100644
--- a/src/views/Results.tsx
+++ b/src/views/Results.tsx
@@ -66,6 +66,7 @@ const Results = () => {
setIsSslLoading(false);
}),
getDomainInfo(domain).then(data => {
+ console.log(data);
setWhoIsData(data);
setIsWhoisLoading(false);
}),