File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -149,14 +149,10 @@ private function add_wildcards($q) {
149149 }
150150
151151 // Add wild card to start of word.
152- if (substr ($ term , 0 , 1 ) != '* ' ) {
153- $ term = '* ' . $ term ;
154- }
152+ $ term = '* ' . trim ($ term , '* ' );
155153
156154 // Add wild card to end of word.
157- if (substr ($ term , -1 , 1 ) != '* ' ) {
158- $ term = $ term . '* ' ;
159- }
155+ $ term = rtrim ($ term , '* ' ) . '* ' ;
160156
161157 $ wildcardterms [] = $ term ;
162158 }
Original file line number Diff line number Diff line change @@ -395,10 +395,18 @@ public function test_construct_wildcard() {
395395 $ proxy = $ method ->invoke (new \search_elastic \query , $ q );
396396 $ this ->assertEquals ('*test* ' , $ proxy );
397397
398+ $ q = 'test** ' ;
399+ $ proxy = $ method ->invoke (new \search_elastic \query , $ q );
400+ $ this ->assertEquals ('*test* ' , $ proxy );
401+
398402 $ q = ' *test ' ;
399403 $ proxy = $ method ->invoke (new \search_elastic \query , $ q );
400404 $ this ->assertEquals ('*test* ' , $ proxy );
401405
406+ $ q = '***test ' ;
407+ $ proxy = $ method ->invoke (new \search_elastic \query , $ q );
408+ $ this ->assertEquals ('*test* ' , $ proxy );
409+
402410 $ q = '*test* ' ;
403411 $ proxy = $ method ->invoke (new \search_elastic \query , $ q );
404412 $ this ->assertEquals ('*test* ' , $ proxy );
You can’t perform that action at this time.
0 commit comments