mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:16:41 +08:00
FIX: Mention lookup should be case insensitive.
This commit is contained in:
parent
3f636b2d19
commit
28a6cf8228
|
@ -429,7 +429,7 @@ module PrettyText
|
|||
|
||||
def self.add_mentions(doc, user_id: nil)
|
||||
elements = doc.css("span.mention")
|
||||
names = elements.map { |element| element.text[1..-1] }
|
||||
names = elements.map { |element| name = element.text[1..-1] }
|
||||
|
||||
mentions = lookup_mentions(names, user_id: user_id)
|
||||
|
||||
|
@ -475,6 +475,7 @@ module PrettyText
|
|||
SQL
|
||||
|
||||
user = User.find_by(id: user_id)
|
||||
names.each(&:downcase!)
|
||||
|
||||
results = DB.query(sql,
|
||||
names: names,
|
||||
|
|
|
@ -221,7 +221,7 @@ describe PrettyText do
|
|||
end
|
||||
|
||||
it "handles user and group mentions correctly" do
|
||||
['user', 'user2'].each do |username |
|
||||
['User', 'user2'].each do |username |
|
||||
Fabricate(:user, username: username)
|
||||
end
|
||||
|
||||
|
@ -231,12 +231,12 @@ describe PrettyText do
|
|||
|
||||
[
|
||||
[
|
||||
'hi @user! @user2 hi',
|
||||
'<p>hi <a class="mention" href="/u/user">@user</a>! <a class="mention" href="/u/user2">@user2</a> hi</p>'
|
||||
'hi @uSer! @user2 hi',
|
||||
'<p>hi <a class="mention" href="/u/user">@uSer</a>! <a class="mention" href="/u/user2">@user2</a> hi</p>'
|
||||
],
|
||||
[
|
||||
"hi\n@user. @#{group.name} @somemention",
|
||||
%Q|<p>hi<br>\n<a class="mention" href="/u/user">@user</a>. <a class="mention-group" href="/groups/#{group.name}">@#{group.name}</a> <span class="mention">@somemention</span></p>|
|
||||
"hi\n@user. @#{group.name.capitalize} @somemention",
|
||||
%Q|<p>hi<br>\n<a class="mention" href="/u/user">@user</a>. <a class="mention-group" href="/groups/#{group.name}">@#{group.name.capitalize}</a> <span class="mention">@somemention</span></p>|
|
||||
]
|
||||
].each do |input, expected|
|
||||
expect(PrettyText.cook(input)).to eq(expected)
|
||||
|
|
Loading…
Reference in New Issue
Block a user