summaryrefslogtreecommitdiff
path: root/lib/couch.ex
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2022-12-20 19:29:21 +0100
committerJordan Bracco <href@random.sh>2022-12-20 19:29:21 +0100
commit6d540163e071d0cf658b8fd16cd1b6af3b494830 (patch)
tree250ab576e596ca8c1188f3003a0cae4585af0724 /lib/couch.ex
parentUpdate ExTwitter to 0.14.0 (diff)
feat(couch): convert slashes to %2F in paths, allowing to use database or docs with slashes in their ids
Diffstat (limited to 'lib/couch.ex')
-rw-r--r--lib/couch.ex12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/couch.ex b/lib/couch.ex
index 71f86a3..e33c045 100644
--- a/lib/couch.ex
+++ b/lib/couch.ex
@@ -73,9 +73,17 @@ defmodule Couch do
config = Application.get_env(:lsg, :couch)
base_url = Keyword.get(config, :url, "http://localhost:5984")
- url = URI.merge(base_url, Path.join(path)) |> to_string()
- headers = headers ++ [{"accept", "application/json"}, {"user-agent", "beautte"}]
+ path = path
+ |> Enum.filter(& &1)
+ |> Enum.map(fn(url) -> String.replace("/", "%2F") end)
+ |> Path.join()
+
+ url = base_url
+ |> URI.merge(path)
+ |> to_string()
+
+ headers = headers ++ [{"accept", "application/json"}, {"user-agent", "#{Nola.brand(:name)} v#{Nola.version()}"}]
params = Enum.map(params, fn({k, v}) -> {to_string(k), v} end)
client_options = Keyword.get(config, :client_options, [])