URI.query_decoder

You're seeing just the function query_decoder, go back to URI module for more information.
Link to this function

query_decoder(query, encoding \\ :www_form)

View Source

Specs

query_decoder(binary(), :rfc3986 | :www_form) :: Enumerable.t()

Returns a stream of two-element tuples representing key-value pairs in the given query.

Key and value in each tuple will be binaries and will be percent-unescaped.

You can specify one of the following encoding options:

  • :www_form - (default, since v1.12.0) keys and values are decoded as per decode_www_form/1. This is the format typically used by browsers on query strings and form data. It decodes "+" as " ".

  • :rfc3986 - (since v1.12.0) keys and values are decoded as per decode/1. The result is the same as :www_form except for leaving "+" as is in line with RFC 3986.

Encoding defaults to :www_form for backward compatibility.

Examples

iex> URI.query_decoder("foo=1&bar=2") |> Enum.to_list()
[{"foo", "1"}, {"bar", "2"}]

iex> URI.query_decoder("food=bread%26butter&drinks=tap%20water+please") |> Enum.to_list()
[{"food", "bread&butter"}, {"drinks", "tap water please"}]

iex> URI.query_decoder("food=bread%26butter&drinks=tap%20water+please", :rfc3986) |> Enum.to_list()
[{"food", "bread&butter"}, {"drinks", "tap water+please"}]