mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Improve regexp for matching version lexeme.
Follow up to b70f1084f7
This commit is contained in:
parent
de5ef5d895
commit
0f53ad58c2
@ -59,7 +59,7 @@ class SearchIndexer
|
|||||||
tsvector.scan(/'(([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+)'\:([\w+,]+)/).reduce(additional_lexemes) do |array, (lexeme, _, positions)|
|
tsvector.scan(/'(([a-zA-Z0-9]+\.)+[a-zA-Z0-9]+)'\:([\w+,]+)/).reduce(additional_lexemes) do |array, (lexeme, _, positions)|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
if lexeme !~ /^(\d+\.)?(\d+\.)?(\*|\d+)$/
|
if lexeme !~ /^(\d+\.)?(\d+\.)*(\*|\d+)$/
|
||||||
loop do
|
loop do
|
||||||
count += 1
|
count += 1
|
||||||
break if count >= 10 # Safeguard here to prevent infinite loop when a term has many dots
|
break if count >= 10 # Safeguard here to prevent infinite loop when a term has many dots
|
||||||
|
@ -143,10 +143,17 @@ describe SearchIndexer do
|
|||||||
|
|
||||||
it 'should not tokenize versions' do
|
it 'should not tokenize versions' do
|
||||||
post.topic.update!(title: "this is a title that I am testing")
|
post.topic.update!(title: "this is a title that I am testing")
|
||||||
post.update!(raw: '1.2.2')
|
post.update!(raw: '123.223')
|
||||||
|
|
||||||
expect(post.post_search_data.search_data).to eq(
|
expect(post.post_search_data.search_data).to eq(
|
||||||
"'1.2.2':10 'test':8A 'titl':4A 'uncategor':9B"
|
"'123.223':10 'test':8A 'titl':4A 'uncategor':9B"
|
||||||
|
)
|
||||||
|
|
||||||
|
post.update!(raw: '15.2.231.423')
|
||||||
|
post.reload
|
||||||
|
|
||||||
|
expect(post.post_search_data.search_data).to eq(
|
||||||
|
"'15.2.231.423':10 'test':8A 'titl':4A 'uncategor':9B"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user