@forcecalendar/core 2.1.39 → 2.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/search/EventSearch.js +11 -4
- package/package.json +1 -1
|
@@ -358,11 +358,18 @@ export class EventSearch {
|
|
|
358
358
|
if (normalizedValue.includes(term)) {
|
|
359
359
|
totalScore += 10;
|
|
360
360
|
}
|
|
361
|
-
// Fuzzy match if enabled
|
|
361
|
+
// Fuzzy match if enabled — compare against individual words
|
|
362
362
|
else if (fuzzy) {
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
const words = normalizedValue.split(/\s+/);
|
|
364
|
+
let bestDistance = Infinity;
|
|
365
|
+
for (const word of words) {
|
|
366
|
+
const distance = this.levenshteinDistance(term, word);
|
|
367
|
+
if (distance < bestDistance) {
|
|
368
|
+
bestDistance = distance;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (bestDistance <= 2) {
|
|
372
|
+
totalScore += 5 - bestDistance;
|
|
366
373
|
}
|
|
367
374
|
}
|
|
368
375
|
}
|