Skip to content

Commit

Permalink
get bunker pubkey from pathname when hostname is empty (#282)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
purrgrammer authored Dec 27, 2024
1 parent 4b5fa3d commit 1762784
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ndk/src/signers/nip46/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 1762784

Please sign in to comment.