Fix Nostr git URL format and npub decoding

- Change URL format from `nostr://<npub>/<domain>/<repo>` to `nostr://<hex-pubkey>/<repo-id>`
- Auto-convert npub to hex pubkey in URL parsing
- Fix hanging issue caused by invalid pubkey format in repository queries
- Update parseRepoUrl in types.ts to handle npub decoding
- Update PullRequestDialog to decode npub before querying
- Update NOSTR_GIT.md with correct URL format examples

The correct format is:
- `nostr://<hex-pubkey>/<repo-id>` (preferred)
- `nostr://<npub>/<repo-id>` (auto-converted to hex)

Fixes the issue where patch publishing would hang indefinitely when trying to query repositories with npub-formatted URLs.
This commit is contained in:
shakespeare.diy committed 2025-10-14 23:49:39 -05:00
1 parent c364b3f796
commit 5047d95cf4
4 files changed
+52 -9

No files matched your search

+20 -2
View File
@@ -1,3 +1,5 @@
import { nip19 } from 'nostr-tools';
/**
* Git host provider abstraction for PR/MR operations
*/
@@ -131,9 +133,25 @@ export function parseRepoUrl(url: string): { owner: string; repo: string } | nul
if (url.startsWith('nostr://')) {
const match = url.match(/^nostr:\/\/([^/]+)\/(.+)$/);
if (match) {
let owner = match[1]; // pubkey in hex or npub
const repo = match[2]; // repo-id (d tag)
// Convert npub to hex if needed
if (owner.startsWith('npub1')) {
try {
const decoded = nip19.decode(owner);
if (decoded.type === 'npub') {
owner = decoded.data;
}
} catch (err) {
console.error('Failed to decode npub:', err);
return null;
}
}
return {
owner: match[1], // pubkey in hex
repo: match[2], // repo-id (d tag)
owner, // pubkey in hex
repo, // repo-id (d tag)
};
}
}