Apply 4 suggestion(s) to 2 file(s)
authorfeld <feld@feld.me>
Sun, 10 Jan 2021 01:34:54 +0000 (01:34 +0000)
committerfeld <feld@feld.me>
Sun, 10 Jan 2021 01:34:54 +0000 (01:34 +0000)
lib/pleroma/upload.ex
lib/pleroma/web/media_proxy.ex

index a52b698bf65a21f98bcb3466ffa43a35e91dcae4..51ca97f41618be7297476a83d50eab82f171935d 100644 (file)
@@ -237,13 +237,7 @@ defmodule Pleroma.Upload do
 
     case uploader do
       Pleroma.Uploaders.Local ->
-        cond do
-          !is_nil(upload_base_url) ->
-            upload_base_url
-
-          true ->
-            Pleroma.Web.base_url() <> "/media/"
-        end
+        upload_base_url || Pleroma.Web.base_url() <> "/media/"
 
       Pleroma.Uploaders.S3 ->
         bucket = Config.get([Pleroma.Uploaders.S3, :bucket])
@@ -260,22 +254,14 @@ defmodule Pleroma.Upload do
               bucket
           end
 
-        cond do
-          !is_nil(public_endpoint) ->
-            Path.join([public_endpoint, bucket_with_namespace])
-
-          true ->
-            Path.join([upload_base_url, bucket_with_namespace])
+        if public_endpoint do
+          Path.join([public_endpoint, bucket_with_namespace])
+        else
+          Path.join([upload_base_url, bucket_with_namespace])
         end
 
       _ ->
-        cond do
-          !is_nil(public_endpoint) ->
-            public_endpoint
-
-          true ->
-            upload_base_url
-        end
+        public_endpoint || upload_base_url
     end
   end
 end
index 95e3f4231a5cfd42666def30aec1511a7080325b..e4d7f8aa8e3bea3617496db6b870f8c6fb9597e9 100644 (file)
@@ -80,13 +80,12 @@ defmodule Pleroma.Web.MediaProxy do
       |> Enum.map(&maybe_get_domain_from_url/1)
 
     whitelist_domains =
-      cond do
-        Web.base_url() == Upload.base_url() ->
-          mediaproxy_whitelist_domains
-
-        true ->
-          %{host: base_domain} = URI.parse(Upload.base_url())
-          [base_domain | mediaproxy_whitelist_domains]
+      base_url = Upload.base_url()
+      if Web.base_url() == base_url do
+        mediaproxy_whitelist_domains
+      else
+        %{host: base_domain} = URI.parse(base_url)
+        [base_domain | mediaproxy_whitelist_domains]
       end
 
     domain in whitelist_domains