Check if rich media uri is relative
This commit is contained in:
parent
833404f0f5
commit
68d461b3a9
|
@ -182,17 +182,18 @@ def render("status.json", _) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("card.json", %{rich_media: rich_media, page_url: page_url}) do
|
def render("card.json", %{rich_media: rich_media, page_url: page_url}) do
|
||||||
page_url = rich_media[:url] || page_url
|
page_url_data =
|
||||||
page_url_data = URI.parse(page_url)
|
if rich_media[:url] != nil do
|
||||||
|
URI.merge(URI.parse(page_url), URI.parse(rich_media[:url]))
|
||||||
|
else
|
||||||
|
page_url
|
||||||
|
end
|
||||||
|
|
||||||
|
page_url = page_url_data |> to_string
|
||||||
|
|
||||||
image_url =
|
image_url =
|
||||||
with %URI{host: nil} <- page_url_data do
|
|
||||||
rich_media[:image]
|
|
||||||
else
|
|
||||||
_ ->
|
|
||||||
URI.merge(page_url_data, URI.parse(rich_media[:image]))
|
URI.merge(page_url_data, URI.parse(rich_media[:image]))
|
||||||
|> to_string
|
|> to_string
|
||||||
end
|
|
||||||
|
|
||||||
site_name = rich_media[:site_name] || page_url_data.host
|
site_name = rich_media[:site_name] || page_url_data.host
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue