You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: exact-match shortcut in BitapSearch bypasses minMatchCharLength #831
Issue: exact-match shortcut in BitapSearch bypasses minMatchCharLength
Bug Description
BitapSearch.searchIn() has a fast-path for the case where pattern === text (the
entire text is an exact match). This path returns isMatch: true immediately — without checking minMatchCharLength. As a result, a document whose value
exactly equals the search pattern is always included in results, even when the
matched region is shorter than the configured minimum.
The non-exact bitap path correctly enforces minMatchCharLength via convertMaskToIndices(..., minMatchCharLength) → sets isMatch = false when no
run is long enough. The shortcut path provides no equivalent guard.
Reproduction
importFusefrom'fuse.js'// Fuse.match APIconstr=Fuse.match('abc','abc',{minMatchCharLength: 5})console.log(r.isMatch)// BUG: true (expected: false — 3 chars < 5)// Corpus searchconstfuse=newFuse(['abc','abcde12345'],{minMatchCharLength: 5})console.log(fuse.search('abc').map(r=>r.item))// BUG: ['abc'] (expected: [] — 'abc' is only 3 characters)
Fix
Add a guard in the exact-match branch of BitapSearch.searchIn():
Fixed on main in dbb98b6. The exact-match shortcut in BitapSearch was skipping minMatchCharLength; it now enforces it the same way the fuzzy path does. Thanks @JSap0914 for the clear repro.
Activity
krisk commentedon Jul 3, 2026
Fixed on main in dbb98b6. The exact-match shortcut in
BitapSearchwas skippingminMatchCharLength; it now enforces it the same way the fuzzy path does. Thanks @JSap0914 for the clear repro.fix(bitap): respect minMatchCharLength in exact-match shortcut
Update dependency fuse.js to v7.5.0 (#27)
⬆️ Update dependency fuse.js to ^7.5.0 (#2044)