AT URI (at://) parsing and validation.
AT URIs reference repositories, collections, and records, for example:
at://did:plc:44ybard66vv44zksje25o7dz/app.bsky.feed.post/3jwdwj2ctlk26This module parses the restricted "well-behaved" form used in Lexicon records (see the AT URI spec):
"at://" AUTHORITY [ "/" COLLECTION [ "/" RKEY ] ] [ "#" FRAGMENT ]where the authority is a DID or handle, the collection is an NSID, and the record key is a valid record key.
Examples
iex> Exosphere.ATProto.AtUri.parse("at://alice.example.com/app.bsky.feed.post/3jwdwj2ctlk26")
{:ok, %Exosphere.ATProto.AtUri{authority: "alice.example.com", collection: "app.bsky.feed.post", rkey: "3jwdwj2ctlk26", fragment: nil}}
iex> Exosphere.ATProto.AtUri.parse("https://example.com")
{:error, :invalid_scheme}
Summary
Functions
Parse an AT URI string into an %Exosphere.ATProto.AtUri{} struct.
Render an %Exosphere.ATProto.AtUri{} struct back to its string form.
Validate an AT URI string.
Types
@type error() ::
:invalid_scheme
| :too_long
| :invalid_authority
| :invalid_collection
| :invalid_rkey
| :rkey_without_collection
| :invalid_fragment
| :invalid_at_uri
Functions
Parse an AT URI string into an %Exosphere.ATProto.AtUri{} struct.
Render an %Exosphere.ATProto.AtUri{} struct back to its string form.
Validate an AT URI string.