Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/banzai/filter/custom_emoji_filter.rb')
-rw-r--r--lib/banzai/filter/custom_emoji_filter.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/banzai/filter/custom_emoji_filter.rb b/lib/banzai/filter/custom_emoji_filter.rb
index 1ee8f4e31e8..3171231dc9b 100644
--- a/lib/banzai/filter/custom_emoji_filter.rb
+++ b/lib/banzai/filter/custom_emoji_filter.rb
@@ -3,6 +3,8 @@
module Banzai
module Filter
class CustomEmojiFilter < HTML::Pipeline::Filter
+ include Gitlab::Utils::StrongMemoize
+
IGNORED_ANCESTOR_TAGS = %w(pre code tt).to_set
def call
@@ -14,7 +16,7 @@ module Banzai
next if has_ancestor?(node, IGNORED_ANCESTOR_TAGS)
next unless content.include?(':')
- next unless namespace && namespace.custom_emoji.any?
+ next unless has_custom_emoji?
html = custom_emoji_name_element_filter(content)
@@ -46,6 +48,12 @@ module Banzai
private
+ def has_custom_emoji?
+ strong_memoize(:has_custom_emoji) do
+ namespace&.custom_emoji&.any?
+ end
+ end
+
def namespace
context[:project].namespace.root_ancestor
end