Workaround for URI.merge/2 bug https://github.com/elixir-lang/elixir/issues/10771
If we avoid URI.merge unless we know we need it we reduce the edge cases we could encounter. The site would need to both have "//" in the %URI{:path} and the image needs to be a relative URL.
This commit is contained in:
parent
8e09a3cfa0
commit
8246db2a96
|
@ -380,9 +380,15 @@ def render("card.json", %{rich_media: rich_media, page_url: page_url}) do
|
||||||
page_url = page_url_data |> to_string
|
page_url = page_url_data |> to_string
|
||||||
|
|
||||||
image_url =
|
image_url =
|
||||||
if is_binary(rich_media["image"]) do
|
cond do
|
||||||
URI.merge(page_url_data, URI.parse(rich_media["image"]))
|
!is_binary(rich_media["image"]) ->
|
||||||
|> to_string
|
nil
|
||||||
|
|
||||||
|
String.starts_with?(rich_media["image"], "http") ->
|
||||||
|
rich_media["image"]
|
||||||
|
|
||||||
|
true ->
|
||||||
|
URI.merge(page_url_data, URI.parse(rich_media["image"])) |> to_string
|
||||||
end
|
end
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
Loading…
Reference in New Issue