Barazo AppView backend barazo.forum
at main 23 lines 600 B view raw
1/** 2 * Extract the rkey (record key) from an AT URI. 3 * Format: at://did:plc:xxx/collection/rkey 4 * 5 * @throws Error if the rkey is missing or empty 6 */ 7export function extractRkey(uri: string): string { 8 const parts = uri.split('/') 9 const rkey = parts[parts.length - 1] 10 if (!rkey) { 11 throw new Error('Invalid AT URI: missing rkey') 12 } 13 return rkey 14} 15 16/** 17 * Extract the collection NSID from an AT URI. 18 * Format: at://did/collection/rkey -> returns "collection" 19 */ 20export function getCollectionFromUri(uri: string): string | undefined { 21 const parts = uri.split('/') 22 return parts[3] 23}