forked from AkkomaGang/akkoma
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
2 changed files with 6 additions and 2 deletions
|
@ -121,6 +121,11 @@ def decode_url(sig, url) do
|
||||||
end
|
end
|
||||||
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
|
defp signed_url(url) do
|
||||||
:crypto.hmac(:sha, Config.get([Web.Endpoint, :secret_key_base]), url)
|
:crypto.hmac(:sha, Config.get([Web.Endpoint, :secret_key_base]), url)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,7 @@ defmodule Pleroma.Web.MediaProxyTest do
|
||||||
alias Pleroma.Web.MediaProxy
|
alias Pleroma.Web.MediaProxy
|
||||||
|
|
||||||
defp decode_result(encoded) do
|
defp decode_result(encoded) do
|
||||||
[_, "proxy", sig, base64 | _] = URI.parse(encoded).path |> String.split("/")
|
{:ok, decoded} = MediaProxy.decode_url(encoded)
|
||||||
{:ok, decoded} = MediaProxy.decode_url(sig, base64)
|
|
||||||
decoded
|
decoded
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue