Fix some link anchors being recognized as hashtags (#27271)
This commit is contained in:
parent
1210524a3d
commit
a89a25714d
2 changed files with 16 additions and 12 deletions
|
@ -33,7 +33,7 @@ class Tag < ApplicationRecord
|
|||
HASTAG_LAST_SEQUENCE = '([[:word:]_]*[[:alpha:]][[:word:]_]*)'
|
||||
HASHTAG_NAME_PAT = "#{HASHTAG_FIRST_SEQUENCE}|#{HASTAG_LAST_SEQUENCE}"
|
||||
|
||||
HASHTAG_RE = /(?:^|[^\/\)\w])#(#{HASHTAG_NAME_PAT})/i
|
||||
HASHTAG_RE = %r{(?<![=/)[:word]])#(#{HASHTAG_NAME_PAT})}i
|
||||
HASHTAG_NAME_RE = /\A(#{HASHTAG_NAME_PAT})\z/i
|
||||
HASHTAG_INVALID_CHARS_RE = /[^[:alnum:]#{HASHTAG_SEPARATORS}]/
|
||||
|
||||
|
|
|
@ -31,6 +31,10 @@ RSpec.describe Tag do
|
|||
expect(subject.match('https://en.wikipedia.org/wiki/Ghostbusters_(song)#Lawsuit')).to be_nil
|
||||
end
|
||||
|
||||
it 'does not match URLs with hashtag-like anchors after an empty query parameter' do
|
||||
expect(subject.match('https://en.wikipedia.org/wiki/Ghostbusters_(song)?foo=#Lawsuit')).to be_nil
|
||||
end
|
||||
|
||||
it 'matches #aesthetic' do
|
||||
expect(subject.match('this is #aesthetic').to_s).to eq '#aesthetic'
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue