Merge remote-tracking branch 'remotes/origin/develop' into media-preview-proxy
[akkoma] / lib / pleroma / instances / instance.ex
index ad7764f05b54145ee912d5dd6124513e12cb14b6..f0f6014690a090b1d97e04f7a47aa4a3b2fe641d 100644 (file)
@@ -157,13 +157,11 @@ defmodule Pleroma.Instances.Instance do
     try do
       with {:ok, %Tesla.Env{body: html}} <-
              Pleroma.HTTP.get(to_string(instance_uri), [{"accept", "text/html"}], pool: :media),
-           favicon_rel <-
-             html
-             |> Floki.parse_document!()
-             |> Floki.attribute("link[rel=icon]", "href")
-             |> List.first(),
-           favicon <- URI.merge(instance_uri, favicon_rel) |> to_string(),
-           true <- is_binary(favicon) do
+           {_, [favicon_rel | _]} when is_binary(favicon_rel) <-
+             {:parse,
+              html |> Floki.parse_document!() |> Floki.attribute("link[rel=icon]", "href")},
+           {_, favicon} when is_binary(favicon) <-
+             {:merge, URI.merge(instance_uri, favicon_rel) |> to_string()} do
         favicon
       else
         _ -> nil