Fix crash while scraping images

This commit is contained in:
Shadowfacts 2019-11-01 18:29:41 -04:00
parent 9264c9a97d
commit c9cc9f2428
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 3 additions and 3 deletions

View File

@ -159,7 +159,7 @@ defmodule Frenzy.Pipeline.ScrapeStage do
{"src", new_src}
_ ->
{"src", image_to_data_uri(convert_to_data_uris, src)}
{"src", image_to_data_uri(src, convert_to_data_uris)}
end
attr ->
@ -176,7 +176,7 @@ defmodule Frenzy.Pipeline.ScrapeStage do
@content_type_allowlist ["image/jpeg", "image/png", "image/heic", "image/heif", "image/tiff"]
# convert images to data URIs so that they're stored by clients as part of the body
defp image_to_data_uri(true, src) do
defp image_to_data_uri(src, true) do
case HTTPoison.get(src) do
{:ok, %HTTPoison.Response{status_code: 200, body: body, headers: headers}} ->
{"Content-Type", content_type} =
@ -193,5 +193,5 @@ defmodule Frenzy.Pipeline.ScrapeStage do
end
end
defp image_to_data_uri(false, src), do: src
defp image_to_data_uri(src, false), do: src
end