Skip to content

Commit 2b63fd9

Browse files
committed
fix bug in MultiInsert neg lookahead. close #28.
1 parent c423bc6 commit 2b63fd9

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

demos/testdata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161867,6 +161867,7 @@
161867161867
"boostedTwo",
161868161868
"boost2threeZ",
161869161869
"TestTraK",
161870+
"aardvark",
161870161871
"Fittest",
161871161872
"ttest",
161872161873
"prometheus_remote_storage_bytes",

dist/uFuzzy.cjs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ function uFuzzy(opts) {
281281
reTpl = parts.map((p, pi) => p.split('').map((c, i, chars) => {
282282
// neg lookahead to prefer matching 'Test' instead of 'tTest' in ManifestTest or fittest
283283
// but skip when search term contains leading repetition (aardvark, aaa)
284-
if (intraIns == 1 && i == 0 && chars.length > 1 && c[i] != c[i+1])
284+
if (intraIns == 1 && i == 0 && chars.length > 1 && c != chars[i+1])
285285
c += '(?!' + c + ')';
286286

287287
return c;
@@ -307,7 +307,7 @@ function uFuzzy(opts) {
307307
// sadly, we also have to capture the inter-term junk via parenth-wrapping .*?
308308
// to accum other capture groups' indices for \b boosting during scoring
309309
reTpl = '(' + reTpl.join(')(' + interCharsTpl + ')(') + ')';
310-
reTpl = '(.?' + preTpl + ')' + reTpl + '(' + sufTpl + '.*)'; // nit: trailing capture here assumes interIns = Inf
310+
reTpl = '(.??' + preTpl + ')' + reTpl + '(' + sufTpl + '.*)'; // nit: trailing capture here assumes interIns = Inf
311311
}
312312
}
313313
else {

dist/uFuzzy.esm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ function uFuzzy(opts) {
279279
reTpl = parts.map((p, pi) => p.split('').map((c, i, chars) => {
280280
// neg lookahead to prefer matching 'Test' instead of 'tTest' in ManifestTest or fittest
281281
// but skip when search term contains leading repetition (aardvark, aaa)
282-
if (intraIns == 1 && i == 0 && chars.length > 1 && c[i] != c[i+1])
282+
if (intraIns == 1 && i == 0 && chars.length > 1 && c != chars[i+1])
283283
c += '(?!' + c + ')';
284284

285285
return c;
@@ -305,7 +305,7 @@ function uFuzzy(opts) {
305305
// sadly, we also have to capture the inter-term junk via parenth-wrapping .*?
306306
// to accum other capture groups' indices for \b boosting during scoring
307307
reTpl = '(' + reTpl.join(')(' + interCharsTpl + ')(') + ')';
308-
reTpl = '(.?' + preTpl + ')' + reTpl + '(' + sufTpl + '.*)'; // nit: trailing capture here assumes interIns = Inf
308+
reTpl = '(.??' + preTpl + ')' + reTpl + '(' + sufTpl + '.*)'; // nit: trailing capture here assumes interIns = Inf
309309
}
310310
}
311311
else {

dist/uFuzzy.iife.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ var uFuzzy = (function () {
282282
reTpl = parts.map((p, pi) => p.split('').map((c, i, chars) => {
283283
// neg lookahead to prefer matching 'Test' instead of 'tTest' in ManifestTest or fittest
284284
// but skip when search term contains leading repetition (aardvark, aaa)
285-
if (intraIns == 1 && i == 0 && chars.length > 1 && c[i] != c[i+1])
285+
if (intraIns == 1 && i == 0 && chars.length > 1 && c != chars[i+1])
286286
c += '(?!' + c + ')';
287287

288288
return c;
@@ -308,7 +308,7 @@ var uFuzzy = (function () {
308308
// sadly, we also have to capture the inter-term junk via parenth-wrapping .*?
309309
// to accum other capture groups' indices for \b boosting during scoring
310310
reTpl = '(' + reTpl.join(')(' + interCharsTpl + ')(') + ')';
311-
reTpl = '(.?' + preTpl + ')' + reTpl + '(' + sufTpl + '.*)'; // nit: trailing capture here assumes interIns = Inf
311+
reTpl = '(.??' + preTpl + ')' + reTpl + '(' + sufTpl + '.*)'; // nit: trailing capture here assumes interIns = Inf
312312
}
313313
}
314314
else {

dist/uFuzzy.iife.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uFuzzy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export default function uFuzzy(opts) {
272272
reTpl = parts.map((p, pi) => p.split('').map((c, i, chars) => {
273273
// neg lookahead to prefer matching 'Test' instead of 'tTest' in ManifestTest or fittest
274274
// but skip when search term contains leading repetition (aardvark, aaa)
275-
if (intraIns == 1 && i == 0 && chars.length > 1 && c[i] != c[i+1])
275+
if (intraIns == 1 && i == 0 && chars.length > 1 && c != chars[i+1])
276276
c += '(?!' + c + ')';
277277

278278
return c;
@@ -298,7 +298,7 @@ export default function uFuzzy(opts) {
298298
// sadly, we also have to capture the inter-term junk via parenth-wrapping .*?
299299
// to accum other capture groups' indices for \b boosting during scoring
300300
reTpl = '(' + reTpl.join(')(' + interCharsTpl + ')(') + ')';
301-
reTpl = '(.?' + preTpl + ')' + reTpl + '(' + sufTpl + '.*)'; // nit: trailing capture here assumes interIns = Inf
301+
reTpl = '(.??' + preTpl + ')' + reTpl + '(' + sufTpl + '.*)'; // nit: trailing capture here assumes interIns = Inf
302302
}
303303
}
304304
else {

0 commit comments

Comments
 (0)