FIX: replace curly quotes to regular quotes in search terms

This commit is contained in:
Arpit Jalan 2017-12-12 11:17:28 +05:30
parent 920571ae07
commit ff6dda85b7
2 changed files with 13 additions and 0 deletions

View File

@ -129,6 +129,8 @@ class Search
# Removes any zero-width characters from search terms
term.to_s.gsub!(/[\u200B-\u200D\uFEFF]/, '')
# Replace curly quotes to regular quotes
term.to_s.gsub!(/[\u201c\u201d]/, '"')
@clean_term = term.to_s.dup
term = process_advanced_search!(term)

View File

@ -71,6 +71,17 @@ describe Search do
expect(search.clean_term).to eq('capybara')
end
it 'replaces curly quotes to regular quotes in search terms' do
term = '“discourse”'
expect(term == '"discourse"').to eq(false)
search = Search.new(term)
expect(search.valid?).to eq(true)
expect(search.term).to eq('"discourse"')
expect(search.clean_term).to eq('"discourse"')
end
it 'does not search when the search term is too small' do
search = Search.new('evil', min_search_term_length: 5)
search.execute