diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 249196fcd13..bad230f57d6 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -440,10 +440,10 @@ module PrettyText case type when USER_TYPE - element['href'] = "/u/#{name}" + element['href'] = "#{Discourse::base_uri}/u/#{name}" when GROUP_TYPE element['class'] = 'mention-group' - element['href'] = "/groups/#{name}" + element['href'] = "#{Discourse::base_uri}/groups/#{name}" end end end diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 1e0cfe9c73c..1490e38b3ac 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -265,6 +265,23 @@ describe PrettyText do end end + context 'subfolder' do + before do + GlobalSetting.stubs(:relative_url_root).returns('/forum') + Discourse.stubs(:base_uri).returns("/forum") + end + + it "handles user and group mentions correctly" do + Fabricate(:user, username: 'user1') + Fabricate(:group, name: 'groupA', mentionable_level: Group::ALIAS_LEVELS[:everyone]) + + input = 'hi there @user1 and @groupA' + expected = '

hi there @user1 and @groupA

' + + expect(PrettyText.cook(input)).to eq(expected) + end + end + it "does not create mention for a non mentionable group" do group = Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:nobody])