Add NostrURI class

This commit is contained in:
Alex Gleason committed 2025-12-23 00:57:18 -06:00
1 parent c84acfdcaa
commit 46a89a67d9
7 files changed
+573 -125

No files matched your search

+3 -3
View File
@@ -8,7 +8,7 @@ import { useAuthor } from '@/hooks/useAuthor';
import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar';
import { genUserName } from '@/lib/genUserName';
import { useNavigate } from 'react-router-dom';
import { nip19 } from 'nostr-tools';
import { NostrURI } from '@/lib/NostrURI';
interface RepositoryCardProps {
repo: Repository;
@@ -22,11 +22,11 @@ export function RepositoryCard({ repo }: RepositoryCardProps) {
const profileImage = authorData?.metadata?.picture;
// Construct Nostr clone URL
const nostrCloneUrl = `nostr://${nip19.npubEncode(repo.pubkey)}/${repo.repoId}`;
const nostrURI = new NostrURI({ pubkey: repo.pubkey, identifier: repo.repoId });
const handleClone = () => {
// Navigate to clone page with Nostr URL parameter
navigate(`/clone?url=${encodeURIComponent(nostrCloneUrl)}`);
navigate(`/clone?url=${encodeURIComponent(nostrURI.toString())}`);
};
return (
@@ -11,11 +11,11 @@ import { useNostr } from '@nostrify/react';
import { useNostrPublish } from '@/hooks/useNostrPublish';
import { useFS } from '@/hooks/useFS';
import { Link } from 'react-router-dom';
import { nip19 } from 'nostr-tools';
import { createRepositoryAnnouncementEvent } from '@/lib/announceRepository';
import { DotAI } from '@/lib/DotAI';
import type { ConfigureRepoStepProps } from '../types';
import type { NostrEvent } from '@nostrify/nostrify';
import { NostrURI } from '@/lib/NostrURI';
export function ConfigureRepoStep({
projectId,
@@ -90,13 +90,13 @@ export function ConfigureRepoStep({
}
// Construct Nostr URI
const nostrUri = `nostr://${nip19.npubEncode(repoEvent.pubkey)}/${projectId}`;
const nostrURI = new NostrURI({ pubkey: repoEvent.pubkey, identifier: projectId });
// Configure the Nostr URI as the origin
await git.addRemote({
dir,
remote: 'origin',
url: nostrUri,
url: nostrURI.toString(),
force: true,
});