mountFor

tcmts.registry.mountFor · #z4sk5r2y · term · runs anywhere

Where a release is mounted in the registry's codebase: by its author's DID (a handle can change, a DID can't), its package and its version, each made a name: plc_ewvi7nxz….geo.v1_3_0.

export function mountFor(did: string, pkg: string, version: string): string {
  const word = (s: string) => {
    const w = s.replace(/[^A-Za-z0-9_$]/g, "_");
    return /^[A-Za-z_$]/.test(w) ? w : `_${w}`;
  };
  const who = did
    .replace(/^did:/, "")
    .replace(/:/g, "_")
    .replace(/[^A-Za-z0-9_]/g, "_");
  return `${word(who)}.${word(pkg.replace(/^@/, ""))}.v${version.replace(/[^A-Za-z0-9]/g, "_")}`;
}

used by