MCPcopy Create free account
hub / github.com/block/buzz / parseProjectRouteId

Function parseProjectRouteId

desktop/src/features/projects/hooks.ts:242–251  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

240 * still resolved, ambiguously, to whichever owner the relay returns first.
241 */
242function 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
253async function fetchProject(projectId: string): Promise<Project | null> {
254 const { owner, dtag } = parseProjectRouteId(projectId);

Callers 1

fetchProjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected