diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js.es6 index 0951d3cdec3..3a8947fef34 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js.es6 +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js.es6 @@ -39,7 +39,7 @@ export function setup(helper) { helper.registerPlugin(md => { const rule = { - matcher: /@\w[\w.-]{0,59}/, + matcher: /@\w[\w.-]{0,58}\w|@\w/, onMatch: addMention }; diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 4135ae6cfe1..2ba1d727713 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -146,10 +146,18 @@ describe PrettyText do expect(PrettyText.cook('@hello @hello @hello')).to match_html "
@hello @hello @hello
" end - it "can handle mentions" do + it "can handle mention edge cases" do + expect(PrettyText.cook("hi\n@s")).to eq("hi
\n@s
hi
\n@ss
hi
\n@s.
hi
\n@s.s
hi
\n@.s.s
hi @sam! hi
' - expect(PrettyText.cook("hi\n@sam")).to eq("hi
\n@sam
hi
\n@sam.