summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2020-11-12 10:17:38 -0600
committerMark Felder <feld@feld.me>2021-05-11 16:50:11 -0500
commitd2f8053552437bae315cc1ed2b55a3d177cfa2be (patch)
treee463e49f789970b1317ffa90aaa580770ee074b3
parent879a94c7558f8b8c82b4e68e428265a127ca58a7 (diff)
Compile the regex
-rw-r--r--lib/pleroma/web/activity_pub/mrf/auto_subject_policy.ex4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/pleroma/web/activity_pub/mrf/auto_subject_policy.ex b/lib/pleroma/web/activity_pub/mrf/auto_subject_policy.ex
index 4b8e8625a..6e74ccc4d 100644
--- a/lib/pleroma/web/activity_pub/mrf/auto_subject_policy.ex
+++ b/lib/pleroma/web/activity_pub/mrf/auto_subject_policy.ex
@@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.AutoSubjectPolicy do
require Pleroma.Constants
require Logger
+ @trim_regex Regex.compile!("[.?!:;]+$")
+
@impl true
def filter(%{"type" => "Create", "actor" => actor, "object" => _object} = message) do
with {:ok, %User{local: true}} <- User.get_or_fetch_by_ap_id(actor),
@@ -84,7 +86,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AutoSubjectPolicy do
|> Enum.uniq()
defp trim_punct(wordlist) when is_list(wordlist),
- do: wordlist |> Enum.map(fn word -> String.replace(word, ~r/[.?!:;]+$/, "") end)
+ do: wordlist |> Enum.map(fn word -> String.replace(word, @trim_regex, "") end)
@impl true
def describe do