MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / parseCompoundId

Function parseCompoundId

packages/core/src/runtime/idCodec.ts:40–57  ·  view source on GitHub ↗
(
  id: string,
  prefix: string,
  expectedSegments: number,
)

Source from the content-addressed store, hash-verified

38 * Parse a compound ID, returning null if prefix doesn't match or segments are invalid.
39 */
40export function parseCompoundId(
41 id: string,
42 prefix: string,
43 expectedSegments: number,
44): readonly string[] | null {
45 if (!id.startsWith(`${prefix}:`)) return null;
46 const body = id.slice(prefix.length + 1);
47 const parts = body.split(":");
48 if (parts.length !== expectedSegments) return null;
49 const decoded: string[] = [];
50 for (const part of parts) {
51 if (part.length === 0) return null;
52 const d = decodeIdSegment(part);
53 if (d === null) return null;
54 decoded.push(d);
55 }
56 return decoded;
57}

Callers 1

idCodec.test.tsFile · 0.90

Calls 2

decodeIdSegmentFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected