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>

Changed files
+19
internal
atproto
+19
internal/atproto/utils/record_utils.go
···
return ""
}
// StringFromNull converts sql.NullString to string
// Returns empty string if the NullString is not valid
func StringFromNull(ns sql.NullString) string {
···
return ""
}
+
// ExtractCollectionFromURI extracts the collection from an AT-URI
+
// Format: at://did/collection/rkey -> collection
+
//
+
// Returns:
+
// - Collection name (e.g., "social.coves.feed.comment") if URI is well-formed
+
// - Empty string if URI is malformed or doesn't contain a collection segment
+
//
+
// Note: Empty string indicates "unknown/unsupported collection" and should be
+
// handled as an invalid or unparseable URI by the caller. Callers should validate
+
// the return value before using it for database queries or business logic.
+
func ExtractCollectionFromURI(uri string) string {
+
withoutScheme := strings.TrimPrefix(uri, "at://")
+
parts := strings.Split(withoutScheme, "/")
+
if len(parts) >= 2 {
+
return parts[1]
+
}
+
return ""
+
}
+
// StringFromNull converts sql.NullString to string
// Returns empty string if the NullString is not valid
func StringFromNull(ns sql.NullString) string {