html.ex: optimize external url extraction
By using a :not() selector and only extracting attributes from the first match.
This commit is contained in:
parent
47ff425cfd
commit
46236d1d87
|
@ -109,8 +109,9 @@ def extract_first_external_url(object, content) do
|
||||||
result =
|
result =
|
||||||
content
|
content
|
||||||
|> Floki.parse_fragment!()
|
|> Floki.parse_fragment!()
|
||||||
|> Floki.filter_out("a.mention,a.hashtag,a.attachment,a[rel~=\"tag\"]")
|
|> Floki.find("a:not(.mention,.hashtag,.attachment,[rel~=\"tag\"])")
|
||||||
|> Floki.attribute("a", "href")
|
|> Enum.take(1)
|
||||||
|
|> Floki.attribute("href")
|
||||||
|> Enum.at(0)
|
|> Enum.at(0)
|
||||||
|
|
||||||
{:commit, {:ok, result}}
|
{:commit, {:ok, result}}
|
||||||
|
|
Loading…
Reference in New Issue