A community based topic aggregation platform built on atproto

docs(utils): enhance ExtractCollectionFromURI documentation

Add comprehensive documentation explaining return value semantics for malformed URIs.

Changes:
- Clarify that empty string indicates "unknown/unsupported collection"
- Document that callers should validate return value before using for DB queries
- Add examples of expected collection names (e.g., "social.coves.feed.comment")
- Explain format expectations (at://did/collection/rkey)

This addresses PR review feedback about input validation documentation. Empty string
is the correct sentinel value indicating unparseable/invalid URIs, and callers must
handle this appropriately.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

+19
+19
internal/atproto/utils/record_utils.go
··· 16 16 return "" 17 17 } 18 18 19 + // ExtractCollectionFromURI extracts the collection from an AT-URI 20 + // Format: at://did/collection/rkey -> collection 21 + // 22 + // Returns: 23 + // - Collection name (e.g., "social.coves.feed.comment") if URI is well-formed 24 + // - Empty string if URI is malformed or doesn't contain a collection segment 25 + // 26 + // Note: Empty string indicates "unknown/unsupported collection" and should be 27 + // handled as an invalid or unparseable URI by the caller. Callers should validate 28 + // the return value before using it for database queries or business logic. 29 + func ExtractCollectionFromURI(uri string) string { 30 + withoutScheme := strings.TrimPrefix(uri, "at://") 31 + parts := strings.Split(withoutScheme, "/") 32 + if len(parts) >= 2 { 33 + return parts[1] 34 + } 35 + return "" 36 + } 37 + 19 38 // StringFromNull converts sql.NullString to string 20 39 // Returns empty string if the NullString is not valid 21 40 func StringFromNull(ns sql.NullString) string {