Skip to content

Commit

Permalink
Follow redirects when fetching remote temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
jerodsanto committed Nov 8, 2022
1 parent 25f58c7 commit 28df1d1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/changelog/kits/url_kit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Changelog.UrlKit do
def get_author(url), do: Person.get_by_website(url)

def get_tempfile(url) do
case HTTP.get(url) do
case HTTP.get(url, [], [follow_redirect: true, max_redirect: 5]) do
{:ok, %{status_code: 200, body: body}} ->
hash = :sha256 |> :crypto.hash(body) |> Base.encode16()
path = Path.join(System.tmp_dir(), hash)
Expand All @@ -25,7 +25,6 @@ defmodule Changelog.UrlKit do
{"Content-Encoding", "x-gzip"} -> :zlib.gunzip(body)
_else -> body
end

_else ->
""
end
Expand Down

0 comments on commit 28df1d1

Please sign in to comment.