Create Pleroma.Maps.put_if_present(map, key, value, value_fun // &{:ok, &1})
Unifies all the similar functions to one and simplify some blocks with it.
This commit is contained in:
parent
f5cb1f3616
commit
54bae06b4f
14 changed files with 59 additions and 106 deletions
|
|
@ -17,14 +17,6 @@ defmodule Pleroma.Helpers.UriHelper do
|
|||
|> URI.to_string()
|
||||
end
|
||||
|
||||
def append_param_if_present(%{} = params, param_name, param_value) do
|
||||
if param_value do
|
||||
Map.put(params, param_name, param_value)
|
||||
else
|
||||
params
|
||||
end
|
||||
end
|
||||
|
||||
def maybe_add_base("/" <> uri, base), do: Path.join([base, uri])
|
||||
def maybe_add_base(uri, _base), do: uri
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue