Merge branch 'streams-fixes' into spc2
This commit is contained in:
commit
428d6e34b5
|
@ -17,6 +17,7 @@ def key_id_to_actor_id(key_id) do
|
||||||
key_id
|
key_id
|
||||||
|> URI.parse()
|
|> URI.parse()
|
||||||
|> Map.put(:fragment, nil)
|
|> Map.put(:fragment, nil)
|
||||||
|
|> remove_query()
|
||||||
|> remove_suffix(@known_suffixes)
|
|> remove_suffix(@known_suffixes)
|
||||||
|
|
||||||
maybe_ap_id = URI.to_string(uri)
|
maybe_ap_id = URI.to_string(uri)
|
||||||
|
@ -33,6 +34,23 @@ def key_id_to_actor_id(key_id) do
|
||||||
end
|
end
|
||||||
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
|
defp remove_suffix(uri, [test | rest]) do
|
||||||
if not is_nil(uri.path) and String.ends_with?(uri.path, test) do
|
if not is_nil(uri.path) and String.ends_with?(uri.path, test) do
|
||||||
Map.put(uri, :path, String.replace(uri.path, test, ""))
|
Map.put(uri, :path, String.replace(uri.path, test, ""))
|
||||||
|
|
Loading…
Reference in New Issue