From a9c1922e513f00628e7f0f7114c4317aab477e3f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 24 Dec 2025 20:46:55 -0600 Subject: [PATCH] Include relay host in Nostr URIs when possible --- src/components/RepositoryCard.tsx | 6 +++++- src/components/git-sync/steps/ConfigureRepoStep.tsx | 6 +++++- src/lib/NostrURI.ts | 2 +- src/lib/git.ts | 8 +++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/RepositoryCard.tsx b/src/components/RepositoryCard.tsx index df200c76..2cd1f718 100644 --- a/src/components/RepositoryCard.tsx +++ b/src/components/RepositoryCard.tsx @@ -34,7 +34,11 @@ export function RepositoryCard({ repo }: RepositoryCardProps) { const profileImage = authorData?.metadata?.picture; // Construct Nostr clone URL - const nostrURI = new NostrURI({ pubkey: repo.pubkey, identifier: repo.repoId }); + const nostrURI = new NostrURI({ + pubkey: repo.pubkey, + identifier: repo.repoId, + relay: repo.relays[0], + }); const handleClone = async (e: React.MouseEvent) => { // Prevent card click from triggering diff --git a/src/components/git-sync/steps/ConfigureRepoStep.tsx b/src/components/git-sync/steps/ConfigureRepoStep.tsx index daf792a0..35ef8eea 100644 --- a/src/components/git-sync/steps/ConfigureRepoStep.tsx +++ b/src/components/git-sync/steps/ConfigureRepoStep.tsx @@ -142,7 +142,11 @@ export function ConfigureRepoStep({ await new Promise(resolve => setTimeout(resolve, 5000)); // Construct Nostr URI - const nostrURI = new NostrURI({ pubkey: repoEvent.pubkey, identifier: projectId }); + const nostrURI = new NostrURI({ + pubkey: repoEvent.pubkey, + identifier: projectId, + relay: [...relays][0], + }); // Configure the Nostr URI as the origin await git.addRemote({ diff --git a/src/lib/NostrURI.ts b/src/lib/NostrURI.ts index acf50f44..3ee5050f 100644 --- a/src/lib/NostrURI.ts +++ b/src/lib/NostrURI.ts @@ -28,7 +28,7 @@ export interface NostrURIParts { * const uri = new NostrURI({ * pubkey: 'abc123...', * identifier: 'my-repo', - * relay: 'relay.example.com' + * relay: 'wss://relay.example.com/' * }); * * // Parse from string diff --git a/src/lib/git.ts b/src/lib/git.ts index 0ec523c1..67cdd92f 100644 --- a/src/lib/git.ts +++ b/src/lib/git.ts @@ -1288,11 +1288,17 @@ export class Git { throw lastError || new Error('All clone attempts failed'); } + // Construct the Nostr URI with relay if not already present + const repoUrl = new NostrURI({ + ...nostrURI.toJSON(), + relay: nostrURI.relay ?? repo.relays[0], + }); + // After successful clone, update the remote to point to the Nostr URI await this.setRemoteURL({ remote: options.remote || 'origin', dir: options.dir, - url: options.url, + url: repoUrl.toString(), }); // Set the nostr.repo config to the naddr