packages/server/src/utils/at-uri.ts 450 B raw
1
export interface AtUriComponents {
2
  did: string;
3
  collection: string;
4
  rkey: string;
5
}
6
7
export function parseAtUri(uri: string): AtUriComponents | null {
8
  const match = uri.match(/^at:\/\/([^/]+)\/([^/]+)\/([^/]+)$/);
9
  if (!match) return null;
10
  return { did: match[1], collection: match[2], rkey: match[3] };
11
}
12
13
export function buildAtUri(did: string, collection: string, rkey: string): string {
14
  return `at://${did}/${collection}/${rkey}`;
15
}