Make nip 05 parsing more permissive

This commit is contained in:
Jon Staab
2025-11-06 10:57:28 -08:00
parent 5345cc1405
commit 6b7e1a5e90
2 changed files with 4 additions and 7 deletions
+3 -7
View File
@@ -11,14 +11,10 @@ export type Handle = {
relays?: string[] relays?: string[]
} }
export const NIP05_REGEX = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/
export async function queryProfile(nip05: string) { export async function queryProfile(nip05: string) {
const match = nip05.match(NIP05_REGEX) const parts = nip05.split("@")
const name = parts.length > 1 ? parts[0] : "_"
if (!match) return undefined const domain = last(parts)
const [_, name = "_", domain] = match
try { try {
const { const {
+1
View File
@@ -5,6 +5,7 @@ export enum ManagementMethod {
SupportedMethods = "supportedmethods", SupportedMethods = "supportedmethods",
BanPubkey = "banpubkey", BanPubkey = "banpubkey",
AllowPubkey = "allowpubkey", AllowPubkey = "allowpubkey",
DisallowPubkey = "disallowpubkey",
ListBannedPubkeys = "listbannedpubkeys", ListBannedPubkeys = "listbannedpubkeys",
ListAllowedPubkeys = "listallowedpubkeys", ListAllowedPubkeys = "listallowedpubkeys",
ListEventsNeedingModeration = "listeventsneedingmoderation", ListEventsNeedingModeration = "listeventsneedingmoderation",