View Source URL.Data (URL v2.0.0)

Parses a data URL

Summary

Functions

Parse a URI with the :scheme of "data"

Types

@type t() :: %URL.Data{
  data: String.t() | {:error, String.t()},
  mediatype: binary(),
  params: map()
}

Functions

@spec parse(URI.t()) :: {:ok, t()} | {:error, {module(), binary()}}

Parse a URI with the :scheme of "data"

Example

iex> data = URI.parse "data:text/plain;base64,SGVsbG8gV29ybGQh"
iex> URL.Data.parse(data)
{:ok,
 %URL.Data{
   mediatype: "text/plain",
   params: %{"encoding" => "base64"},
   data: "Hello World!"
 }}