* Splits a project route ID into its owner pubkey and dtag. The canonical * form is ` : ` (matching `Project.id`) — NIP-34 repo * identity is the full `30617: : ` coordinate, and two owners can * both publish the same dtag (forks). Bare-dtag IDs from legacy links are
(projectId: string)
| 240 | * still resolved, ambiguously, to whichever owner the relay returns first. |
| 241 | */ |
| 242 | function parseProjectRouteId(projectId: string): { |
| 243 | owner: string | null; |
| 244 | dtag: string; |
| 245 | } { |
| 246 | const owner = projectId.slice(0, 64); |
| 247 | if (projectId[64] === ":" && /^[0-9a-fA-F]{64}$/.test(owner)) { |
| 248 | return { owner: owner.toLowerCase(), dtag: projectId.slice(65) }; |
| 249 | } |
| 250 | return { owner: null, dtag: projectId }; |
| 251 | } |
| 252 | |
| 253 | async function fetchProject(projectId: string): Promise<Project | null> { |
| 254 | const { owner, dtag } = parseProjectRouteId(projectId); |