Skip to content

Commit

Permalink
Merge branch 'ex_aws_24'
Browse files Browse the repository at this point in the history
# Conflicts:
#	mix.lock
  • Loading branch information
bettyblocks-release-bot committed Aug 13, 2024
2 parents d8444c8 + 4f2cdcc commit 3d59660
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/ex_aws/auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule ExAws.Auth do

@moduledoc false

@allowed_subresources ~w(acl cors lifecycle location logging notification partNumber policy requestPayment uploadId uploads versionId versioning versions website)
@unsignable_headers ["x-amzn-trace-id"]
@unsignable_headers_multi_case ["x-amzn-trace-id", "X-Amzn-Trace-Id"]

Expand Down Expand Up @@ -312,17 +313,23 @@ defmodule ExAws.Auth do

defp canonical_query(""), do: ""
defp canonical_query(query) do
"?" <> query
query
|> String.split("&")
|> Enum.map(fn chunk ->
case chunk |> String.split("=") do
[param, ""] -> param
[param, value] -> "#{param}=#{value}"
|> Enum.flat_map(fn chunk ->
case String.split(chunk, "=") do
[param, ""] when param in @allowed_subresources -> [param]
[param, value] when param in @allowed_subresources -> ["#{param}=#{value}"]
[_, _] -> []
end
end)
|> Enum.join("&")
|> prepend_question_mark
end

@spec prepend_question_mark(binary) :: binary
defp prepend_question_mark(""), do: ""
defp prepend_question_mark(query_string), do: "?#{query_string}"

defp remove_dup_spaces(str), do: remove_dup_spaces(str, "")
defp remove_dup_spaces(str, str), do: str

Expand Down

0 comments on commit 3d59660

Please sign in to comment.