File tree 4 files changed +27
-2
lines changed
4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1
1
# CHANGELOG
2
+ ## 0.2.2
3
+ - Fix bug for search in a list with some string that has leading or trailing whitespace when tokenize option is true
4
+
2
5
## 0.2.1
3
6
- Fix bug for search empty list
4
7
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ class Fuzzy<T> {
81
81
for (var i = 0 , len = list.length; i < len; i += 1 ) {
82
82
_analyze (
83
83
key: '' ,
84
- value: list[i].toString (),
84
+ value: list[i].toString (). trim () ,
85
85
record: list[i],
86
86
index: i,
87
87
tokenSearchers: tokenSearchers,
Original file line number Diff line number Diff line change 1
1
name : fuzzy
2
- version : 0.2.1
2
+ version : 0.2.2
3
3
4
4
authors :
5
5
- Igor Borges <igor@borges.dev>
Original file line number Diff line number Diff line change @@ -210,6 +210,28 @@ void main() {
210
210
});
211
211
});
212
212
213
+ group (
214
+ 'Search with match all tokens in a list of strings with leading and trailing whitespace' ,
215
+ () {
216
+ Fuzzy fuse;
217
+ setUp (() {
218
+ final customList = [' Apple' , 'Orange ' , ' Banana ' ];
219
+ fuse = setup (
220
+ itemList: customList,
221
+ overwriteOptions: FuzzyOptions (tokenize: true ),
222
+ );
223
+ });
224
+
225
+ test ('When searching for the term "Banana"' , () {
226
+ final result = fuse.search ('Banana' );
227
+
228
+ expect (result.length, 1 , reason: 'we get a list of exactly 1 item' );
229
+ expect (result[0 ].item, equals (' Banana ' ),
230
+ reason:
231
+ 'whose value is the same, disconsidering leading and trailing whitespace' );
232
+ });
233
+ });
234
+
213
235
group ('Search with match all tokens' , () {
214
236
Fuzzy fuse;
215
237
setUp (() {
You can’t perform that action at this time.
0 commit comments