Thread viewer for Bluesky
1import { URLError } from '../api.js';
2
3export class AtURI {
4 repo: string;
5 collection: string;
6 rkey: string;
7
8 constructor(uri: string) {
9 if (!uri.startsWith('at://')) {
10 throw new URLError(`Not an at:// URI: ${uri}`);
11 }
12
13 let parts = uri.split('/');
14
15 if (parts.length != 5) {
16 throw new URLError(`Invalid at:// URI: ${uri}`);
17 }
18
19 this.repo = parts[2];
20 this.collection = parts[3];
21 this.rkey = parts[4];
22 }
23}
24
25export function atURI(uri: string): AtURI {
26 return new AtURI(uri);
27}