- # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber.StripTags) it is assumed it is always 0)
- version =
- if Kernel.function_exported?(scrubber, :version, 0) do
- scrubber.version
- else
- 0
- end
-
- "#{signature}#{to_string(scrubber)}#{version}"
+ "#{signature}#{to_string(scrubber)}"
+ end)
+ end
+
+ def extract_first_external_url(_, nil), do: {:error, "No content"}
+
+ def extract_first_external_url(object, content) do
+ key = "URL|#{object.id}"
+
+ Cachex.fetch!(:scrubber_cache, key, fn _key ->
+ result =
+ content
+ |> Floki.filter_out("a.mention")
+ |> Floki.attribute("a", "href")
+ |> Enum.at(0)
+
+ {:commit, {:ok, result}}