Add replacement for $
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
84b4368211
commit
6fe062ed6c
1 changed files with 9 additions and 0 deletions
|
@ -1020,6 +1020,7 @@ defp replace_instance_host(value, nil), do: value
|
|||
defp replace_instance_host(content, host) when is_binary(content) do
|
||||
content
|
||||
|> String.replace("$INSTANCE$host$", host)
|
||||
|> String.replace("$INSTANCE$tld$", get_tld(host, "$INSTANCE$tld$"))
|
||||
end
|
||||
|
||||
defp replace_instance_host(object, host) when is_map(object) do
|
||||
|
@ -1031,6 +1032,14 @@ defp replace_instance_host(object, host) when is_map(object) do
|
|||
|
||||
defp replace_instance_host(value, _), do: value
|
||||
|
||||
defp get_tld(host, default) do
|
||||
with [domain | _] <- String.split(host, ".") |> Enum.reverse() do
|
||||
domain
|
||||
else
|
||||
_ -> default
|
||||
end
|
||||
end
|
||||
|
||||
defp patch_content_map(%{"contentMap" => %{} = content_map}, host) do
|
||||
content_map
|
||||
|> Enum.map(fn {key, value} -> {key, replace_instance_host(value, host)} end)
|
||||
|
|
Loading…
Reference in a new issue