Skip to content

Full Toolkit for Next-Level Domain Analysis

Fix lookup edge cases not being recorded correctly ✅

Felix Wotschofsky3e8e9014aee3
diff --git a/lib/search.ts b/lib/search.ts
index 9a316a0..10e8d4a 100644
--- a/lib/search.ts
+++ b/lib/search.ts
@@ -8,7 +8,10 @@ export const recordLookup = (data: { domain: string; isBot: boolean }) => {
return;
}
- const baseDomain = getDomain(data.domain);
+ // Remove wildcard prefix to avoid base domain not being extracted correctly
+ // Remove trailing dot
+ const cleanedDomain = data.domain.replace(/^\*\./, '').replace(/\.$/, '');
+ const baseDomain = getDomain(cleanedDomain) || cleanedDomain;
const forwardedFor = headers().get('x-forwarded-for');
const ip = (forwardedFor ?? '127.0.0.1').split(',')[0];
diff --git a/lib/utils.ts b/lib/utils.ts
index 1bd9816..a585cbb 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -23,7 +23,7 @@ export const isValidDomain = (domain: string) => {
if (!regexResult) return false;
// Remove wildcard prefix to avoid false negatives from library
- const cleanedDomain = domain.startsWith('*.') ? domain.slice(2) : domain;
+ const cleanedDomain = domain.replace(/^\*\./, '');
try {
const result = tldtsParse(cleanedDomain);
return result.isIcann || result.isPrivate;