catch fetch error on nip05.

This commit is contained in:
fiatjaf 2023-03-02 08:20:13 -03:00
parent e48d722227
commit 086f8830e3
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
2 changed files with 9 additions and 4 deletions

View File

@ -38,9 +38,14 @@ export async function queryProfile(
if (!name.match(/^[A-Za-z0-9-_]+$/)) return null
let res = await (
await _fetch(`https://${domain}/.well-known/nostr.json?name=${name}`)
).json()
let res
try {
res = await (
await _fetch(`https://${domain}/.well-known/nostr.json?name=${name}`)
).json()
} catch (err) {
return null
}
if (!res?.names?.[name]) return null

View File

@ -1,6 +1,6 @@
{
"name": "nostr-tools",
"version": "1.7.1",
"version": "1.7.2",
"description": "Tools for making a Nostr client.",
"repository": {
"type": "git",