Skip to content

Commit 8f67ac9

Browse files
committed
fix(extended): ignoreLocation when useExtendedSearch is true
Fixes #465
1 parent 302a44d commit 8f67ac9

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

dist/fuse.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,9 @@
14311431
_ref$minMatchCharLeng = _ref.minMatchCharLength,
14321432
minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
14331433
_ref$isCaseSensitive = _ref.isCaseSensitive,
1434-
isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive;
1434+
isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
1435+
_ref$ignoreLocation = _ref.ignoreLocation,
1436+
ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
14351437

14361438
_classCallCheck(this, FuzzyMatch);
14371439

@@ -1443,7 +1445,8 @@
14431445
includeMatches: includeMatches,
14441446
findAllMatches: findAllMatches,
14451447
minMatchCharLength: minMatchCharLength,
1446-
isCaseSensitive: isCaseSensitive
1448+
isCaseSensitive: isCaseSensitive,
1449+
ignoreLocation: ignoreLocation
14471450
});
14481451
return _this;
14491452
}
@@ -1620,6 +1623,8 @@
16201623
includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
16211624
_ref$minMatchCharLeng = _ref.minMatchCharLength,
16221625
minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
1626+
_ref$ignoreLocation = _ref.ignoreLocation,
1627+
ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation,
16231628
_ref$findAllMatches = _ref.findAllMatches,
16241629
findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
16251630
_ref$location = _ref.location,
@@ -1637,6 +1642,7 @@
16371642
includeMatches: includeMatches,
16381643
minMatchCharLength: minMatchCharLength,
16391644
findAllMatches: findAllMatches,
1645+
ignoreLocation: ignoreLocation,
16401646
location: location,
16411647
threshold: threshold,
16421648
distance: distance

src/search/extended/FuzzyMatch.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export default class FuzzyMatch extends BaseMatch {
1212
includeMatches = Config.includeMatches,
1313
findAllMatches = Config.findAllMatches,
1414
minMatchCharLength = Config.minMatchCharLength,
15-
isCaseSensitive = Config.isCaseSensitive
15+
isCaseSensitive = Config.isCaseSensitive,
16+
ignoreLocation = Config.ignoreLocation
1617
} = {}
1718
) {
1819
super(pattern)
@@ -23,7 +24,8 @@ export default class FuzzyMatch extends BaseMatch {
2324
includeMatches,
2425
findAllMatches,
2526
minMatchCharLength,
26-
isCaseSensitive
27+
isCaseSensitive,
28+
ignoreLocation
2729
})
2830
}
2931
static get type() {

src/search/extended/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default class ExtendedSearch {
4242
isCaseSensitive = Config.isCaseSensitive,
4343
includeMatches = Config.includeMatches,
4444
minMatchCharLength = Config.minMatchCharLength,
45+
ignoreLocation = Config.ignoreLocation,
4546
findAllMatches = Config.findAllMatches,
4647
location = Config.location,
4748
threshold = Config.threshold,
@@ -54,6 +55,7 @@ export default class ExtendedSearch {
5455
includeMatches,
5556
minMatchCharLength,
5657
findAllMatches,
58+
ignoreLocation,
5759
location,
5860
threshold,
5961
distance

test/extended-search.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,25 @@ describe('Searching using extended search', () => {
8787
expect(result).toMatchSnapshot()
8888
})
8989
})
90+
91+
describe('ignoreLocation when useExtendedSearch is true', () => {
92+
const list = [
93+
{
94+
document:
95+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum apple.'
96+
}
97+
]
98+
99+
test('Search: literal match with fuzzy match', () => {
100+
const options = {
101+
threshold: 0.2,
102+
useExtendedSearch: true,
103+
ignoreLocation: true,
104+
keys: ['document']
105+
}
106+
const fuse = new Fuse(list, options)
107+
108+
let result = fuse.search('Apple')
109+
expect(result).toHaveLength(1)
110+
})
111+
})

0 commit comments

Comments
 (0)