fix: prevent bare dot from triggering NIP-05 redirect in search

This commit is contained in:
Chad Curtis
2026-03-03 04:33:10 -06:00
parent 3801b007e8
commit dee47c0907
+7 -2
View File
@@ -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;