https://github.com/nallwhy/doumi_uri_query
A Elixir helper library that supports encoding complicated query of URI.
https://github.com/nallwhy/doumi_uri_query
elixir
Last synced: about 1 year ago
JSON representation
A Elixir helper library that supports encoding complicated query of URI.
- Host: GitHub
- URL: https://github.com/nallwhy/doumi_uri_query
- Owner: nallwhy
- License: mit
- Created: 2022-12-03T01:19:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-03T08:21:39.000Z (over 3 years ago)
- Last Synced: 2025-06-11T03:41:14.037Z (about 1 year ago)
- Topics: elixir
- Language: Elixir
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Doumi.URI.Query
[](https://hex.pm/packages/doumi_uri_query)
[](https://hexdocs.pm/doumi_uri_query/)
[](https://github.com/nallwhy/doumi_uri_query/blob/master/LICENSE.md)
[](https://github.com/nallwhy/doumi_uri_query/commits/main)
`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)
```elixir
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](https://hexdocs.pm/doumi_uri_query/), the package can be installed
by adding `doumi_phoenix_svg` to your list of dependencies in `mix.exs`:
```elixir
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](https://github.com/nallwhy/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](./LICENSE.md) file for more details.