mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 02:05:12 +00:00
Merge branch 'mediaproxy-decode' into 'develop'
Simple way to decode mediaproxy URLs See merge request pleroma/pleroma!3364
This commit is contained in:
commit
a9bc652ab9
|
@ -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
|
||||
|
|
|
@ -11,8 +11,7 @@ defmodule Pleroma.Web.MediaProxyTest do
|
|||
alias Pleroma.Web.MediaProxy
|
||||
|
||||
defp decode_result(encoded) do
|
||||
[_, "proxy", sig, base64 | _] = URI.parse(encoded).path |> String.split("/")
|
||||
{:ok, decoded} = MediaProxy.decode_url(sig, base64)
|
||||
{:ok, decoded} = MediaProxy.decode_url(encoded)
|
||||
decoded
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue