fix bug encoding query string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95a8c96..067ac29 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
# Changelog
+## v0.3.2
+
+[bug fix]
+- Fix setting the query string bug (typo) - `url.encode_query(qs_map)` -> `URI.encode_query(qs_map)`
+
## v0.3.1
[changes]
diff --git a/lib/ex_ovh/transformation/url.ex b/lib/ex_ovh/transformation/url.ex
index a49b4b4..56348ae 100644
--- a/lib/ex_ovh/transformation/url.ex
+++ b/lib/ex_ovh/transformation/url.ex
@@ -14,19 +14,15 @@ defmodule ExOvh.Transformation.Url do
|> Map.put(:completed_transformations, trans ++ [:url])
end
@spec apply(HTTPipe.Conn.t, map, atom) :: HTTPipe.Conn.t
- def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string, client) when query_string == %{} do
- ovh_config = client.ovh_config()
- trans = Map.get(conn, :completed_transformations, [])
- url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url
- request = Map.put(conn.request, :url, url)
- Map.put(conn, :request, request)
- |> Map.put(:completed_transformations, trans ++ [:url])
+ def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string_map, client) when query_string_map == %{} do
+ apply(conn, client)
end
- def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string, client) do
+ def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string_map, client) do
ovh_config = client.ovh_config()
trans = Map.get(conn, :completed_transformations, [])
- url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url <> "?" <> (query_string |> url.encode_query())
+ url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url
request = Map.put(conn.request, :url, url)
+ |> add_query_string(query_string_map)
Map.put(conn, :request, request)
|> Map.put(:completed_transformations, trans ++ [:url])
end
@@ -34,7 +30,7 @@ defmodule ExOvh.Transformation.Url do
@doc ~S"""
Add the request string to a request from a map of `name`=`value` elements. Use instead of
- `ExOvh.Transformation.url.apply/3` when the `client` is not available but the request should
+ `ExOvh.Transformation.Url.apply/3` when the `client` is not available but the request should
be modified without marking it as fully `transformed` with :url.
To be used for GET requests.
@@ -53,7 +49,7 @@ defmodule ExOvh.Transformation.Url do
@spec add_query_string(HTTPipe.Request.t, map) :: HTTPipe.Request.t
def add_query_string(%HTTPipe.Request{} = request, qs_map) when qs_map == %{}, do: request
def add_query_string(%HTTPipe.Request{url: url} = request, qs_map) do
- url = url <> "?" <> url.encode_query(qs_map)
+ url = url <> "?" <> URI.encode_query(qs_map)
Map.put(request, :url, url)
end
diff --git a/lib/ex_ovh/v1/cloud.ex b/lib/ex_ovh/v1/cloud.ex
index c917754..9393d01 100644
--- a/lib/ex_ovh/v1/cloud.ex
+++ b/lib/ex_ovh/v1/cloud.ex
@@ -1,6 +1,6 @@
defmodule ExOvh.V1.Cloud do
@moduledoc ~s"""
- Helper functions for building queries directed at the cloudstorage related parts of the `/cloud` part of the [OVH API](https://api.ovh.com/console/).
+ Helper functions for building requests directed at the cloudstorage related parts of the `/cloud` part of the [OVH API](https://api.ovh.com/console/).
See `ExOvh.V1.Cloud` for generic cloud requests.
diff --git a/mix.exs b/mix.exs
index 59a727e..eb53f6a 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,6 +1,6 @@
defmodule ExOvh.Mixfile do
use Mix.Project
- @version "0.3.1"
+ @version "0.3.2"
@elixir ">= 1.2.0"
def project do