/doumi_uri_query

A Elixir helper library that supports encoding complicated query of URI.

Primary LanguageElixirMIT LicenseMIT

Doumi.URI.Query

Hex Version Hex Docs License Last Updated

Doumi.URI.Query is a helper library that supports encoding complicated query of URI.

도우미(Doumi) means "helper" in Korean.

Usage

It's common to send nested maps or lists via query string even though it is not standardized.

URI.encode_query/2 does not support nested maps or lists and can't be customized to handle that.

Doumi.URI.Query supports encoding maps or lists to query string. (only PHP-style now)

iex> query = %{"foo" => %{"bar" => 1, "baz" => 2}}
iex> Doumi.URI.Query.encode(query)
"foo%5Bbar%5D=1&foo%5Bbaz%5D=2" # foo[bar]=1&foo[baz]=2

iex> query = %{"foo" => [1, 2, 3]}
iex> Doumi.URI.Query.encode(query)
"foo%5B%5D=1&foo%5B%5D=2&foo%5B%5D=3" # foo[]=1&foo[]=2&foo[]=3

Installation

If available in Hex, the package can be installed by adding doumi_phoenix_svg to your list of dependencies in mix.exs:

def deps do
  [
    {:doumi_uri_query, "~> 0.1.0"}
  ]
end

TODO

  • Support encode list like "foo=1&foo=2&foo=3"
  • Support encode list like "foo=1,2,3"

Other Doumi packages

  • Doumi.Phoenix.SVG: A helper library that generates Phoenix function components from SVG files.

Copyright and License

Copyright (c) 2022 Jinkyou Son (Json)

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE.md file for more details.