mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 19:47:14 +00:00
Allow using ideographic space (U+3000) as a separator for search terms (#37878).
Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@21952 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
fcf1352c6b
commit
b9379e7a26
@ -135,7 +135,7 @@ module Redmine
|
||||
def tokens
|
||||
# extract tokens from the question
|
||||
# eg. hello "bye bye" => ["hello", "bye bye"]
|
||||
tokens = @question.scan(%r{((\s|^)"[^"]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}
|
||||
tokens = @question.scan(%r{(([[:space:]]|^)"[^"]+"([[:space:]]|$)|[[:^space:]]+)}).collect {|m| m.first.gsub(%r{(^[[:space:]]*"[[:space:]]*|[[:space:]]*"[[:space:]]*$)}, '')}
|
||||
# tokens must be at least 2 characters long
|
||||
# but for Chinese characters (Chinese HANZI/Japanese KANJI), tokens can be one character
|
||||
# no more than 5 tokens to search for
|
||||
|
||||
@ -24,4 +24,10 @@ class Redmine::Search::Tokenize < ActiveSupport::TestCase
|
||||
value = "hello \"bye bye\""
|
||||
assert_equal ["hello", "bye bye"], Redmine::Search::Tokenizer.new(value).tokens
|
||||
end
|
||||
|
||||
def test_tokenize_should_consider_ideographic_space_as_separator
|
||||
# U+3000 is an ideographic space (" ")
|
||||
value = "全角\u3000スペース"
|
||||
assert_equal %w[全角 スペース], Redmine::Search::Tokenizer.new(value).tokens
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user