From cddecdec68f9934640cd55722cc532a9ec19ea19 Mon Sep 17 00:00:00 2001 From: Benton Date: Fri, 2 Sep 2022 09:23:51 -0400 Subject: [PATCH 1/2] Fix fuseOpts not propogating certain values due to boolean coercion i.e. if params.fuseOpts.threshold is 0.0 or params.fuseOpts.ignorelocation is false, the default values of 0.4 and true will still be used. --- assets/js/fastsearch.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/assets/js/fastsearch.js b/assets/js/fastsearch.js index 02d1396ac6..97e2879cc8 100644 --- a/assets/js/fastsearch.js +++ b/assets/js/fastsearch.js @@ -28,17 +28,17 @@ window.onload = function () { }; if (params.fuseOpts) { options = { - isCaseSensitive: params.fuseOpts.iscasesensitive ? params.fuseOpts.iscasesensitive : false, - includeScore: params.fuseOpts.includescore ? params.fuseOpts.includescore : false, - includeMatches: params.fuseOpts.includematches ? params.fuseOpts.includematches : false, - minMatchCharLength: params.fuseOpts.minmatchcharlength ? params.fuseOpts.minmatchcharlength : 1, - shouldSort: params.fuseOpts.shouldsort ? params.fuseOpts.shouldsort : true, - findAllMatches: params.fuseOpts.findallmatches ? params.fuseOpts.findallmatches : false, - keys: params.fuseOpts.keys ? params.fuseOpts.keys : ['title', 'permalink', 'summary', 'content'], - location: params.fuseOpts.location ? params.fuseOpts.location : 0, - threshold: params.fuseOpts.threshold ? params.fuseOpts.threshold : 0.4, - distance: params.fuseOpts.distance ? params.fuseOpts.distance : 100, - ignoreLocation: params.fuseOpts.ignorelocation ? params.fuseOpts.ignorelocation : true + isCaseSensitive: params.fuseOpts.iscasesensitive ?? false, + includeScore: params.fuseOpts.includescore ?? false, + includeMatches: params.fuseOpts.includematches ?? false, + minMatchCharLength: params.fuseOpts.minmatchcharlength ?? 1, + shouldSort: params.fuseOpts.shouldsort ?? true, + findAllMatches: params.fuseOpts.findallmatches ?? false, + keys: params.fuseOpts.keys ?? ['title', 'permalink', 'summary', 'content'], + location: params.fuseOpts.location ?? 0, + threshold: params.fuseOpts.threshold ?? 0.4, + distance: params.fuseOpts.distance ?? 100, + ignoreLocation: params.fuseOpts.ignorelocation ?? true } } fuse = new Fuse(data, options); // build the index from the json file From fdcebbc6c35bb072875c0560131ee375bdb2faa8 Mon Sep 17 00:00:00 2001 From: Benton Date: Fri, 2 Sep 2022 09:36:16 -0400 Subject: [PATCH 2/2] fixed spacing --- assets/js/fastsearch.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/assets/js/fastsearch.js b/assets/js/fastsearch.js index 97e2879cc8..06ebcfba79 100644 --- a/assets/js/fastsearch.js +++ b/assets/js/fastsearch.js @@ -28,17 +28,17 @@ window.onload = function () { }; if (params.fuseOpts) { options = { - isCaseSensitive: params.fuseOpts.iscasesensitive ?? false, - includeScore: params.fuseOpts.includescore ?? false, - includeMatches: params.fuseOpts.includematches ?? false, - minMatchCharLength: params.fuseOpts.minmatchcharlength ?? 1, - shouldSort: params.fuseOpts.shouldsort ?? true, - findAllMatches: params.fuseOpts.findallmatches ?? false, - keys: params.fuseOpts.keys ?? ['title', 'permalink', 'summary', 'content'], - location: params.fuseOpts.location ?? 0, - threshold: params.fuseOpts.threshold ?? 0.4, - distance: params.fuseOpts.distance ?? 100, - ignoreLocation: params.fuseOpts.ignorelocation ?? true + isCaseSensitive: params.fuseOpts.iscasesensitive ?? false, + includeScore: params.fuseOpts.includescore ?? false, + includeMatches: params.fuseOpts.includematches ?? false, + minMatchCharLength: params.fuseOpts.minmatchcharlength ?? 1, + shouldSort: params.fuseOpts.shouldsort ?? true, + findAllMatches: params.fuseOpts.findallmatches ?? false, + keys: params.fuseOpts.keys ?? ['title', 'permalink', 'summary', 'content'], + location: params.fuseOpts.location ?? 0, + threshold: params.fuseOpts.threshold ?? 0.4, + distance: params.fuseOpts.distance ?? 100, + ignoreLocation: params.fuseOpts.ignorelocation ?? true } } fuse = new Fuse(data, options); // build the index from the json file