Remove line break after linking username mentions (#15788)
This commit is contained in:
parent
dfb0d0300c
commit
3fd03b5ed6
3 changed files with 8 additions and 2 deletions
|
|
@ -280,7 +280,7 @@ module Html
|
|||
def user_link_if_exists(mention)
|
||||
username = mention.delete("@").downcase
|
||||
if User.find_by(username: username)
|
||||
<<~HTML
|
||||
<<~HTML.chomp
|
||||
<a class='mentioned-user' href='#{ApplicationConfig['APP_PROTOCOL']}#{Settings::General.app_domain}/#{username}'>@#{username}</a>
|
||||
HTML
|
||||
else
|
||||
|
|
|
|||
|
|
@ -400,6 +400,12 @@ RSpec.describe Html::Parser, type: :service do
|
|||
parsed_html = described_class.new(html).wrap_mentions_with_links.html
|
||||
expect(parsed_html).to include("<a")
|
||||
end
|
||||
|
||||
it "does not add an extra return" do
|
||||
html = "@#{user.username}"
|
||||
parsed_html = described_class.new(html).wrap_mentions_with_links.html
|
||||
expect(parsed_html).not_to include("\n")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#parse_emojis" do
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ RSpec.describe MarkdownProcessor::Parser, type: :service do
|
|||
# rubocop:disable Layout/LineLength
|
||||
expected_result = "<p><code>@#{user.username}</code> one two, <a class=\"mentioned-user\" " \
|
||||
"href=\"#{ApplicationConfig['APP_PROTOCOL']}#{ApplicationConfig['APP_DOMAIN']}/#{user.username}\">" \
|
||||
"@#{user.username}</a>\n three four:</p>\n\n<ul>\n<li><code>@#{user.username}</code></li>\n</ul>\n\n"
|
||||
"@#{user.username}</a> three four:</p>\n\n<ul>\n<li><code>@#{user.username}</code></li>\n</ul>\n\n"
|
||||
# rubocop:enable Layout/LineLength
|
||||
expect(result).to eq(expected_result)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue