Check if rich media uri is relative
authorrinpatch <rinpatch@sdf.org>
Sat, 2 Feb 2019 09:24:24 +0000 (12:24 +0300)
committerrinpatch <rinpatch@sdf.org>
Sat, 2 Feb 2019 09:24:24 +0000 (12:24 +0300)
lib/pleroma/web/mastodon_api/views/status_view.ex

index c8fde93bae6a66b078036a2bcacbb7b0a8407a26..d1b11d4f10288c9db64e6aa6e7c91df76104f994 100644 (file)
@@ -182,18 +182,19 @@ 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)
-
-    image_url =
-      with %URI{host: nil} <- page_url_data do
-        rich_media[:image]
+    page_url_data =
+      if rich_media[:url] != nil do
+        URI.merge(URI.parse(page_url), URI.parse(rich_media[:url]))
       else
-        _ ->
-          URI.merge(page_url_data, URI.parse(rich_media[:image]))
-          |> to_string
+        page_url
       end
 
+    page_url = page_url_data |> to_string
+
+    image_url =
+      URI.merge(page_url_data, URI.parse(rich_media[:image]))
+      |> to_string
+
     site_name = rich_media[:site_name] || page_url_data.host
 
     %{