summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-09-02 12:42:25 +0300
committerrinpatch <rinpatch@sdf.org>2020-09-02 12:45:20 +0300
commit46236d1d873473d95b11cd7bfdcaa284ea55a9ad (patch)
tree027c393ebf76ba5f5b13fbd30879175987efb080
parent47ff425cfd53212aba26e9eba86de16e3ef1442b (diff)
html.ex: optimize external url extraction
By using a :not() selector and only extracting attributes from the first match.
-rw-r--r--lib/pleroma/html.ex5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex
index dc1b9b840..20b02f091 100644
--- a/lib/pleroma/html.ex
+++ b/lib/pleroma/html.ex
@@ -109,8 +109,9 @@ defmodule Pleroma.HTML do
result =
content
|> Floki.parse_fragment!()
- |> Floki.filter_out("a.mention,a.hashtag,a.attachment,a[rel~=\"tag\"]")
- |> Floki.attribute("a", "href")
+ |> Floki.find("a:not(.mention,.hashtag,.attachment,[rel~=\"tag\"])")
+ |> Enum.take(1)
+ |> Floki.attribute("href")
|> Enum.at(0)
{:commit, {:ok, result}}