aboutsummaryrefslogtreecommitdiff
path: root/backend/general/utils.go
blob: fe0854a8c9dd67f4f6b6cfb88cd955c65f44fd99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package general

import (
	"fmt"
	"strings"
)

func ParseURI(uri string) (repo, collection, rkey string, err error) {
	// URI format: 'at://DID/collection/recordkey'
	parts := strings.Split(strings.TrimPrefix(uri, "at://"), "/")
	if len(parts) != 3 {
		return "", "", "", fmt.Errorf("invalid URI format: %s", uri)
	}

	return parts[0], parts[1], parts[2], nil
}