VBT.URI (vbt v0.1.0) View Source
Encoding and decoding of VBT URIs.
A VBT URI is a special format of URI where path, query, and fragment parts are encoded into the fragment. For example, a standard URI http://some.host/some/path?foo=1#some_fragment is represented as http://some.host/#!some/path?foo=1#some_fragment.
This special URI format is introduced to support deep links with applications deployed to S3. By encoding everything into fragment, we make sure that every link always points to the root (index.html) on the S3 server.
Link to this section Summary
Functions
Parses a well-formed VBT URI string into its components.
Returns the string representation of the given URI, encoded in VBT format.
Link to this section Functions
Specs
Parses a well-formed VBT URI string into its components.
iex> VBT.URI.parse("http://foo.bar:4000/#!some/path?foo=1&bar=2#some_fragment")
%URI{
scheme: "http",
host: "foo.bar",
port: 4000,
path: "/some/path",
query: "foo=1&bar=2",
fragment: "some_fragment",
userinfo: nil,
authority: "foo.bar:4000",
}
If the input is not a valid VBT URI, this function will raise an argument error.
Specs
Returns the string representation of the given URI, encoded in VBT format.
iex> uri = %URI{
...> scheme: "http",
...> host: "foo.bar",
...> port: 4000,
...> path: "/some/path",
...> query: "foo=1&bar=2",
...> fragment: "some_fragment"
...> }
iex> VBT.URI.to_string(uri)
"http://foo.bar:4000/#!some/path?foo=1&bar=2#some_fragment"