Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/search/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def sanitize(terms)
end

def remove_invalid_search_characters(terms)
terms.gsub(/[^\w"]/, " ")
terms.gsub(/[^[[:word:]]"]/, " ")
end

def remove_unbalanced_quotes(terms)
Expand Down
2 changes: 1 addition & 1 deletion app/models/search/stemmer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Search::Stemmer

def stem(value)
if value.present?
value.gsub(/[^\w\s]/, " ").split(/\s+/).map { |word| STEMMER.stem(word.downcase) }.join(" ")
value.gsub(/[^[[:word:]]\s]/, " ").split(/\s+/).map { |word| STEMMER.stem(word.downcase) }.join(" ")
else
value
end
Expand Down
7 changes: 7 additions & 0 deletions test/models/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ class SearchTest < ActiveSupport::TestCase
results = Search::Record.for(@user.account_id).search("BC3-IOS-1D8B", user: @user)
assert results.find { |it| it.card_id == card.id }
end

test "search for non-Latin (e.g. Cyrillic) strings" do
card = @board.cards.create!(title: "фільтрувати картки", creator: @user, status: "published")

results = Search::Record.for(@user.account_id).search("картки", user: @user)
assert results.find { |it| it.card_id == card.id }
Comment on lines +49 to +50
end
end