Remove line break after linking username mentions (#15788)

This commit is contained in:
Josh Puetz 2021-12-16 10:39:07 -06:00 committed by GitHub
parent dfb0d0300c
commit 3fd03b5ed6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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