nil
end
- image_url = get_image_url(image_url_data, page_url_data)
+ image_url = build_image_url(image_url_data, page_url_data)
%{
type: "link",
# Avoid applying URI.merge unless necessary
# TODO: revert to always attempting URI.merge(image_url_data, page_url_data)
# when Elixir 1.12 is the minimum supported version
- @spec get_image_url(struct() | nil, struct()) :: String.t() | nil
- defp get_image_url(
+ @spec build_image_url(struct() | nil, struct()) :: String.t() | nil
+ defp build_image_url(
%URI{scheme: image_scheme, host: image_host} = image_url_data,
%URI{} = _page_url_data
)
image_url_data |> to_string
end
- defp get_image_url(%URI{} = image_url_data, %URI{} = page_url_data) do
+ defp build_image_url(%URI{} = image_url_data, %URI{} = page_url_data) do
URI.merge(page_url_data, image_url_data) |> to_string
end
- defp get_image_url(_, _), do: nil
+ defp build_image_url(_, _), do: nil
end