View Source URL.Data (URL v1.5.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()) :: 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)
%URL.Data{
  data: "Hello World!",
  mediatype: "text/plain",
  params: %{"encoding" => "base64"}
}