From 1762784a0532084d16401dfb018d63bd0f9cb127 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Fri, 27 Dec 2024 14:49:15 +0100 Subject: [PATCH] get bunker pubkey from pathname when hostname is empty (#282) I'm running into an issue where the bunker pubkey is not set when trying to use bunker URLs from nsec.app like bunker://4b5893bff39aca8e3e3813c190156165e706d15d4f6136d718158ef957f26309?relay=wss://relay.nsec.app&secret=secret-value. The `hostname` is empty and the `pathname` is `//4b5893bff39aca8e3e3813c190156165e706d15d4f6136d718158ef957f26309`. This PR makes sure to get the pubkey from pathname when the hostname is empty. --- ndk/src/signers/nip46/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndk/src/signers/nip46/index.ts b/ndk/src/signers/nip46/index.ts index 08f65eb9..0b7072bd 100644 --- a/ndk/src/signers/nip46/index.ts +++ b/ndk/src/signers/nip46/index.ts @@ -95,7 +95,7 @@ export class NDKNip46Signer extends EventEmitter implements NDKSigner { private connectionTokenInit(connectionToken: string) { const bunkerUrl = new URL(connectionToken); - const bunkerPubkey = bunkerUrl.hostname; + const bunkerPubkey = bunkerUrl.hostname || bunkerUrl.pathname.replace(/^\/\//, ""); const userPubkey = bunkerUrl.searchParams.get("pubkey"); const relayUrls = bunkerUrl.searchParams.getAll("relay"); const secret = bunkerUrl.searchParams.get("secret");