From 086f8830e31a45f87a8e67591da338b942deda43 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 2 Mar 2023 08:20:13 -0300 Subject: [PATCH] catch fetch error on nip05. --- nip05.ts | 11 ++++++++--- package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/nip05.ts b/nip05.ts index 2cc9869..cb86604 100644 --- a/nip05.ts +++ b/nip05.ts @@ -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 diff --git a/package.json b/package.json index 71b86ba..6ed9736 100644 --- a/package.json +++ b/package.json @@ -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",