Skip to content

Commit dbb98b6

Browse files
committed
fix(bitap): respect minMatchCharLength in exact-match shortcut
BitapSearch.searchIn()'s exact-match fast path (pattern === text) returned isMatch: true without checking minMatchCharLength, so a value that exactly equals the query matched even when shorter than the configured minimum. The fuzzy path already enforces this via convertMaskToIndices; the shortcut now mirrors it, returning a non-match when text.length < minMatchCharLength. Also covers the empty-pattern/empty-text case (default minMatchCharLength 1) and the token-search path, which wraps per-term BitapSearch instances. Closes #831
1 parent e2ee793 commit dbb98b6

13 files changed

Lines changed: 76 additions & 5 deletions

dist/fuse.basic.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ var BitapSearch = class {
575575
text = isCaseSensitive ? text : text.toLowerCase();
576576
text = ignoreDiacritics ? stripDiacritics(text) : text;
577577
if (this.pattern === text) {
578+
if (text.length < this.options.minMatchCharLength) return {
579+
isMatch: false,
580+
score: 1
581+
};
578582
const result = {
579583
isMatch: true,
580584
score: 0

dist/fuse.basic.min.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.basic.min.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.basic.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ var BitapSearch = class {
574574
text = isCaseSensitive ? text : text.toLowerCase();
575575
text = ignoreDiacritics ? stripDiacritics(text) : text;
576576
if (this.pattern === text) {
577+
if (text.length < this.options.minMatchCharLength) return {
578+
isMatch: false,
579+
score: 1
580+
};
577581
const result = {
578582
isMatch: true,
579583
score: 0

dist/fuse.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ var BitapSearch = class {
572572
text = isCaseSensitive ? text : text.toLowerCase();
573573
text = ignoreDiacritics ? stripDiacritics(text) : text;
574574
if (this.pattern === text) {
575+
if (text.length < this.options.minMatchCharLength) return {
576+
isMatch: false,
577+
score: 1
578+
};
575579
const result = {
576580
isMatch: true,
577581
score: 0

dist/fuse.min.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.min.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ var BitapSearch = class {
571571
text = isCaseSensitive ? text : text.toLowerCase();
572572
text = ignoreDiacritics ? stripDiacritics(text) : text;
573573
if (this.pattern === text) {
574+
if (text.length < this.options.minMatchCharLength) return {
575+
isMatch: false,
576+
score: 1
577+
};
574578
const result = {
575579
isMatch: true,
576580
score: 0

dist/fuse.worker.min.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fuse.worker.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ var BitapSearch = class {
560560
text = isCaseSensitive ? text : text.toLowerCase();
561561
text = ignoreDiacritics ? stripDiacritics(text) : text;
562562
if (this.pattern === text) {
563+
if (text.length < this.options.minMatchCharLength) return {
564+
isMatch: false,
565+
score: 1
566+
};
563567
const result = {
564568
isMatch: true,
565569
score: 0

0 commit comments

Comments
 (0)