properly get actor from key id for Streams.
This commit is contained in:
parent
7fca598268
commit
aee44ac25e
|
@ -17,6 +17,7 @@ def key_id_to_actor_id(key_id) do
|
|||
key_id
|
||||
|> URI.parse()
|
||||
|> Map.put(:fragment, nil)
|
||||
|> remove_query()
|
||||
|> remove_suffix(@known_suffixes)
|
||||
|
||||
maybe_ap_id = URI.to_string(uri)
|
||||
|
@ -33,6 +34,23 @@ def key_id_to_actor_id(key_id) do
|
|||
end
|
||||
end
|
||||
|
||||
defp remove_query(uri) do
|
||||
if uri.query do
|
||||
new_query =
|
||||
URI.decode_query(uri.query)
|
||||
|> Map.delete("operation")
|
||||
|> URI.encode_query()
|
||||
|> case do
|
||||
"" -> nil
|
||||
query -> query
|
||||
end
|
||||
|
||||
Map.put(uri, :query, new_query)
|
||||
else
|
||||
uri
|
||||
end
|
||||
end
|
||||
|
||||
defp remove_suffix(uri, [test | rest]) do
|
||||
if not is_nil(uri.path) and String.ends_with?(uri.path, test) do
|
||||
Map.put(uri, :path, String.replace(uri.path, test, ""))
|
||||
|
|
Loading…
Reference in New Issue