mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
ignore HTTP redirect in nip05
This commit is contained in:
committed by
fiatjaf_
parent
b9435af708
commit
8c78649d5c
10
nip05.ts
10
nip05.ts
@@ -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]
|
||||||
|
|||||||
Reference in New Issue
Block a user