forked from potsda.mn/mobilizon
Fix path issue when fetching favicon for resources
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
c4f8fe0fe8
commit
386dbbb3a6
|
@ -60,12 +60,16 @@ defmodule Mobilizon.Service.RichMedia.Favicon do
|
|||
uri = URI.parse(url)
|
||||
|
||||
cond do
|
||||
is_nil(image_uri.host) -> "#{uri.scheme}://#{uri.host}#{path}"
|
||||
is_nil(image_uri.host) -> "#{uri.scheme}://#{uri.host}#{correct_path(path)}"
|
||||
is_nil(image_uri.scheme) -> "#{uri.scheme}:#{path}"
|
||||
true -> path
|
||||
end
|
||||
end
|
||||
|
||||
# Sometimes paths have "/" in front, sometimes not
|
||||
defp correct_path("/" <> _ = path), do: path
|
||||
defp correct_path(path), do: "/#{path}"
|
||||
|
||||
@spec find_favicon_link_tag(String.t()) :: {:ok, tuple()} | {:error, any()}
|
||||
defp find_favicon_link_tag(html) do
|
||||
with {:ok, html} <- Floki.parse_document(html),
|
||||
|
|
Loading…
Reference in a new issue