Fix mentions regex to exclude usernames in Medium URLs
This commit is contained in:
@ -111,4 +111,28 @@ RSpec.describe Account, type: :model do
|
||||
describe '.find_local' do
|
||||
pending
|
||||
end
|
||||
|
||||
describe 'MENTION_RE' do
|
||||
subject { Account::MENTION_RE }
|
||||
|
||||
it 'matches usernames in the middle of a sentence' do
|
||||
expect(subject.match('Hello to @alice from me')[1]).to eq 'alice'
|
||||
end
|
||||
|
||||
it 'matches usernames in the beginning of status' do
|
||||
expect(subject.match('@alice Hey how are you?')[1]).to eq 'alice'
|
||||
end
|
||||
|
||||
it 'matches dot-prepended usernames' do
|
||||
expect(subject.match('.@alice I want everybody to see this')[1]).to eq 'alice'
|
||||
end
|
||||
|
||||
it 'does not match e-mails' do
|
||||
expect(subject.match('Drop me an e-mail at alice@example.com')).to be_nil
|
||||
end
|
||||
|
||||
it 'does not match URLs' do
|
||||
expect(subject.match('Check this out https://medium.com/@alice/some-article#.abcdef123')).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user