Fix error when attempting to convert image w/o Content-Type header to data URI

This commit is contained in:
Shadowfacts 2020-10-24 13:37:06 -04:00
parent 3bbf42df75
commit 8e18a415eb
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 6 additions and 6 deletions

View File

@ -144,13 +144,13 @@ defmodule Frenzy.Pipeline.ScrapeStage do
case Network.http_get(absolute_url) do case Network.http_get(absolute_url) do
{:ok, %Mojito.Response{body: body, headers: headers}} -> {:ok, %Mojito.Response{body: body, headers: headers}} ->
{"Content-Type", content_type} = Enum.find(headers, fn {header, _value} -> header == "Content-Type" end)
Enum.find(headers, fn {header, _value} -> header == "Content-Type" end) |> case do
{"Content-Type", content_type} when content_type in @content_type_allowlist ->
"data:#{content_type};base64,#{Base.encode64(body)}"
if content_type in @content_type_allowlist do _ ->
"data:#{content_type};base64,#{Base.encode64(body)}" src
else
src
end end
_ -> _ ->