Polyjuice Util v0.2.1 Polyjuice.Util.URI View Source
Link to this section Summary
Types
For users, room IDs and room aliases, identifier
is a string. For events,
it is of the form {room_id_or_alias, event_id}
. And for media, it is of the
form {server, id}
.
Link to this section Types
For users, room IDs and room aliases, identifier
is a string. For events,
it is of the form {room_id_or_alias, event_id}
. And for media, it is of the
form {server, id}
.
Link to this section Functions
Functions for using Matrix URIs
Supports matrix.to
, matrix:
, and mxc:
URIs, and supports referencing
users, rooms (by ID or alias), events (using room ID or room alias), and
media (mxc:
URIs only).
Parse a Matrix URI.
Examples
iex> Polyjuice.Util.URI.parse("matrix:u/hubert:uhoreg.ca")
{:ok, %Polyjuice.Util.URI{
type: :user,
identifier: "@hubert:uhoreg.ca",
query_params: []
}}
iex> Polyjuice.Util.URI.parse("https://matrix.to/#/%40hubert:uhoreg.ca")
{:ok, %Polyjuice.Util.URI{
type: :user,
identifier: "@hubert:uhoreg.ca",
query_params: []
}}
Generate a Matrix URI.
format
indicates what URI format to generate. Currently, it defaults to
matrix_to
; in the future when the matrix
format is supported by more
clients, the default may change to that. If you require a certain format,
you should specify it rather than relying on the default behaviour. :media
URIs will always be mxc:
URIs, regardless of the format
.
Examples
iex> Polyjuice.Util.URI.to_string(
...> %Polyjuice.Util.URI{type: :user, identifier: "@hubert:uhoreg.ca"},
...> :matrix
...> )
"matrix:u/hubert%3Auhoreg.ca"
iex> Polyjuice.Util.URI.to_string(
...> %Polyjuice.Util.URI{type: :user, identifier: "@hubert:uhoreg.ca"},
...> :matrix_to
...> )
"https://matrix.to/#/%40hubert%3Auhoreg.ca"