From 68d461b3a9f3be58af85a7ae98ace2ebcbc616f2 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sat, 2 Feb 2019 12:24:24 +0300 Subject: [PATCH] Check if rich media uri is relative --- .../web/mastodon_api/views/status_view.ex | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index c8fde93ba..d1b11d4f1 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -182,17 +182,18 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do end def render("card.json", %{rich_media: rich_media, page_url: page_url}) do - page_url = rich_media[:url] || page_url - page_url_data = URI.parse(page_url) + page_url_data = + 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 = - with %URI{host: nil} <- page_url_data do - rich_media[:image] - else - _ -> - URI.merge(page_url_data, URI.parse(rich_media[:image])) - |> to_string - end + URI.merge(page_url_data, URI.parse(rich_media[:image])) + |> to_string site_name = rich_media[:site_name] || page_url_data.host