Skip to content

Commit

Permalink
Remove + replace for the path in sanitize, it's not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryjj committed Jul 22, 2020
1 parent 315ead6 commit 2581fa1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/ex_aws/request/url.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ defmodule ExAws.Request.Url do
|> String.replace_prefix("/", "")
|> uri_encode()

require Logger
Logger.error("new_path #{new_path}")

query =
case String.split(url, "?", parts: 2) do
[_] -> nil
Expand All @@ -63,7 +66,7 @@ defmodule ExAws.Request.Url do
url
|> URI.parse()
|> Map.put(:fragment, nil)
|> Map.put(:path, "/" <> String.replace(new_path, "+", "%2B"))
|> Map.put(:path, "/" <> new_path)
|> Map.put(:query, query_replace_spaces(query))
|> URI.to_string()
end
Expand Down
4 changes: 2 additions & 2 deletions test/ex_aws/request/url_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ defmodule ExAws.Request.UrlTest do

describe "sanitize" do
test "it URI encodes spaces, + and unicode characters in the path" do
url = "s3://my-bucket/uploads/a key with ++"
assert Url.sanitize(url, :s3) == "s3://my-bucket/uploads/a%20key%20with%20%2B%2B"
url = "s3://my-bucket/upl+oads/a key with ++"
assert Url.sanitize(url, :s3) == "s3://my-bucket/upl%2Boads/a%20key%20with%20%2B%2B"
end

test "it URI encodes unicode characters in the path" do
Expand Down

0 comments on commit 2581fa1

Please sign in to comment.