ignore HTTP redirect in nip05

This commit is contained in:
Shusui MOYATANI
2024-02-09 21:50:07 +09:00
committed by fiatjaf_
parent b9435af708
commit 8c78649d5c

View File

@@ -21,9 +21,10 @@ export function useFetchImplementation(fetchImplementation: any) {
export async function searchDomain(domain: string, query = ''): Promise<{ [name: string]: string }> { export async function searchDomain(domain: string, query = ''): Promise<{ [name: string]: string }> {
try { try {
let res = await (await _fetch(`https://${domain}/.well-known/nostr.json?name=${query}`)).json() const url = `https://${domain}/.well-known/nostr.json?name=${query}`
const res = await _fetch(url, { redirect: 'error' })
return res.names const json = await res.json()
return json.names
} catch (_) { } catch (_) {
return {} return {}
} }
@@ -36,7 +37,8 @@ export async function queryProfile(fullname: string): Promise<ProfilePointer | n
const [_, name = '_', domain] = match const [_, name = '_', domain] = match
try { try {
const res = await _fetch(`https://${domain}/.well-known/nostr.json?name=${name}`) const url = `https://${domain}/.well-known/nostr.json?name=${name}`
const res = await _fetch(url, { redirect: 'error' })
const { names, relays } = parseNIP05Result(await res.json()) const { names, relays } = parseNIP05Result(await res.json())
const pubkey = names[name] const pubkey = names[name]