From dee47c090777863fb5879e42255c2f856d3aa55d Mon Sep 17 00:00:00 2001 From: Chad Curtis Date: Tue, 3 Mar 2026 04:33:10 -0600 Subject: [PATCH] fix: prevent bare dot from triggering NIP-05 redirect in search --- src/lib/nostrIdentifier.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/nostrIdentifier.ts b/src/lib/nostrIdentifier.ts index 0d5c186e..860d8595 100644 --- a/src/lib/nostrIdentifier.ts +++ b/src/lib/nostrIdentifier.ts @@ -21,8 +21,13 @@ function looksLikeNip05(value: string): boolean { const atIndex = cleaned.indexOf('@'); return atIndex > 0 && atIndex < cleaned.length - 1 && cleaned.slice(atIndex + 1).includes('.'); } - // bare domain — contains a dot but isn't a NIP-19 identifier - if (cleaned.includes('.') && !NIP19_PREFIXES.some((p) => cleaned.startsWith(p))) { + // bare domain — must look like "something.tld" with non-empty parts on both sides of the dot + const dotIndex = cleaned.indexOf('.'); + if ( + dotIndex > 0 && + dotIndex < cleaned.length - 1 && + !NIP19_PREFIXES.some((p) => cleaned.startsWith(p)) + ) { return true; } return false;