A platform for community discussion. Free, open, simple.
FIX: remove "fake" mentions from extract_mentions (#26253)
Sam34a14112a70e
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rbindex 17c0ab06f0f..aed31e1a912 100644--- a/lib/pretty_text.rb+++ b/lib/pretty_text.rb@@ -464,11 +464,9 @@ module PrettyTextmentions =cooked.css(".mention, .mention-group")- .map do |e|+ .filter_map do |e|if (name = e.inner_text)- name = name[1..-1]- name = User.normalize_username(name)- name+ User.normalize_username(name[1..-1]) if name[0] == "@"endenddiff --git a/spec/lib/pretty_text_spec.rb b/spec/lib/pretty_text_spec.rbindex 24bd6c79b0d..fef6b44ba4e 100644--- a/spec/lib/pretty_text_spec.rb+++ b/spec/lib/pretty_text_spec.rb@@ -569,13 +569,13 @@ RSpec.describe PrettyText do<a class="mention" href="/u/test">@test</a>,<a class="mention-group" href="/g/test-group">@test-group</a>,<a class="custom-mention" href="/custom-mention">@test-custom</a>,+ <a class="mention" href="/u/test1">test1</a>,this is a test</p>HTMLextracted_mentions = PrettyText.extract_mentions(Nokogiri::HTML5.fragment(cooked_html))- expect(extracted_mentions).to include("test", "test-group")- expect(extracted_mentions).not_to include("test-custom")+ expect(extracted_mentions).to contain_exactly("test", "test-group")Plugin::Instance.new