Add Pleroma.Test.Helpers.get_query_parameter/2 to retrieve specific query parameter values

This commit is contained in:
Mark Felder 2024-01-15 17:32:15 -05:00
parent 4cbf11d32c
commit 8bd8ee03c2
1 changed files with 11 additions and 0 deletions

View File

@ -32,6 +32,17 @@ def uri_query_sort(uri) do
|> URI.to_string() |> URI.to_string()
end end
@doc "Returns the value of the specified query parameter for the provided URL"
def get_query_parameter(url, param) do
url
|> URI.parse()
|> Map.get(:query)
|> URI.query_decoder()
|> Enum.to_list()
|> Enum.into(%{}, fn {x, y} -> {x, y} end)
|> Map.get(param)
end
defmacro clear_config(config_path) do defmacro clear_config(config_path) do
quote do quote do
clear_config(unquote(config_path)) do clear_config(unquote(config_path)) do