Skip to content

Full Toolkit for Next-Level Domain Analysis

Use Array.toSorted 👌

Felix Wotschofsky36edb7408a35
diff --git a/app/lookup/[domain]/certs/page.tsx b/app/lookup/[domain]/certs/page.tsx
index 1cbf5ba..cd68b9d 100644
--- a/app/lookup/[domain]/certs/page.tsx
+++ b/app/lookup/[domain]/certs/page.tsx
@@ -63,7 +63,7 @@ const CertsResultsPage: FC<CertsResultsPageProps> = async ({
const certs = await Promise.all(certRequests).then((responses) =>
responses
.flat()
- .sort(
+ .toSorted(
(a, b) =>
new Date(b.entry_timestamp).getTime() -
new Date(a.entry_timestamp).getTime()
diff --git a/app/lookup/[domain]/subdomains/page.tsx b/app/lookup/[domain]/subdomains/page.tsx
index 4b45a0e..2bf1457 100644
--- a/app/lookup/[domain]/subdomains/page.tsx
+++ b/app/lookup/[domain]/subdomains/page.tsx
@@ -76,12 +76,12 @@ const SubdomainsResultsPage: FC<SubdomainsResultsPageProps> = async ({
domain,
firstSeen: issuedCerts
.filter((c) => c.domains.includes(domain))
- .sort((a, b) => a.date.getTime() - b.date.getTime())[0].date,
+ .toSorted((a, b) => a.date.getTime() - b.date.getTime())[0].date,
stillExists: hasRecords,
};
})
);
- const sortedResults = results.sort(
+ const sortedResults = results.toSorted(
(a, b) => b.firstSeen.getTime() - a.firstSeen.getTime()
);
diff --git a/components/DnsTable.tsx b/components/DnsTable.tsx
index 38c9101..195c874 100644
--- a/components/DnsTable.tsx
+++ b/components/DnsTable.tsx
@@ -42,8 +42,7 @@ const DnsTable: FC<DnsTableProps> = ({ records }) => (
</TableHeader>
<TableBody>
{value
- .slice()
- .sort((a, b) => naturalCompare(a.data, b.data))
+ .toSorted((a, b) => naturalCompare(a.data, b.data))
.map((v) => (
<RecordRow key={v.type + v.data} record={v} />
))}
diff --git a/components/IpDetailsModal.tsx b/components/IpDetailsModal.tsx
index 37e1862..f1378d7 100644
--- a/components/IpDetailsModal.tsx
+++ b/components/IpDetailsModal.tsx
@@ -73,14 +73,11 @@ const IpDetailsModal: FC<IpDetailsModalProps> = ({
label: 'IP',
value: ip,
},
- ...data.reverse
- .slice()
- .sort(naturalCompare)
- .map((address) => ({
- type: EntryTypes.Reverse,
- label: 'Reverse',
- value: address,
- })),
+ ...data.reverse.toSorted(naturalCompare).map((address) => ({
+ type: EntryTypes.Reverse,
+ label: 'Reverse',
+ value: address,
+ })),
{
type: EntryTypes.Organization,
label: 'Organization',
diff --git a/components/ResultsGlobe.tsx b/components/ResultsGlobe.tsx
index 709ab76..e9e1d80 100644
--- a/components/ResultsGlobe.tsx
+++ b/components/ResultsGlobe.tsx
@@ -75,7 +75,7 @@ const ResultsGlobe: FC<ResultsGlobeProps> = ({ domain, markers }) => {
d.results.A.length
? h(
'div',
- d.results.A.sort(naturalCompare)
+ d.results.A.toSorted(naturalCompare)
.slice(0, d.results.A.length > 5 ? 4 : 5)
.map((value) =>
h('p.text-xs.text-muted-foreground', value)
@@ -92,7 +92,7 @@ const ResultsGlobe: FC<ResultsGlobeProps> = ({ domain, markers }) => {
d.results.AAAA.length
? h(
'div',
- d.results.AAAA.sort(naturalCompare)
+ d.results.AAAA.toSorted(naturalCompare)
.slice(0, d.results.AAAA.length > 5 ? 4 : 5)
.map((value) =>
h('p.text-xs.text-muted-foreground', value)
@@ -109,7 +109,7 @@ const ResultsGlobe: FC<ResultsGlobeProps> = ({ domain, markers }) => {
d.results.CNAME.length
? h(
'div',
- d.results.CNAME.sort(naturalCompare)
+ d.results.CNAME.toSorted(naturalCompare)
.slice(0, d.results.CNAME.length > 5 ? 4 : 5)
.map((value) =>
h('p.text-xs.text-muted-foreground', value)