Add simple way to decode fully qualified mediaproxy URLs
authorMark Felder <feld@feld.me>
Fri, 5 Mar 2021 19:18:37 +0000 (13:18 -0600)
committerMark Felder <feld@feld.me>
Fri, 5 Mar 2021 19:18:37 +0000 (13:18 -0600)
lib/pleroma/web/media_proxy.ex

index 27f3371389edbb5178e5b6435f746b2d19c65be6..d0d4bb4b3d81a66cbbe02579faa1ba9f10f8fc2c 100644 (file)
@@ -121,6 +121,11 @@ defmodule Pleroma.Web.MediaProxy do
     end
   end
 
+  def decode_url(encoded) do
+    [_, "proxy", sig, base64 | _] = URI.parse(encoded).path |> String.split("/")
+    decode_url(sig, base64)
+  end
+
   defp signed_url(url) do
     :crypto.hmac(:sha, Config.get([Web.Endpoint, :secret_key_base]), url)
   end