Skip to content

Commit

Permalink
Update search-results.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kailasnadh790 committed Apr 2, 2024
1 parent aa06ead commit c156e5e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cigaradvisor/blocks/search-results/search-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ function filterData(searchTerms, data) {
searchTerms.forEach((term) => {
const regex = new RegExp(term, 'gi');
// Search in rank order
const titleParts = result.title ? result.title.split(regex) : [];
let found = result.title ? [...result.title.matchAll(regex)] : [];
if (found.length) {
if (found.length || titleParts.length > 1) {
rank = 1;
count += found.length;
count += found.length + titleParts.length;
}

found = result.heading ? [...result.heading.matchAll(regex)] : [];
Expand All @@ -49,7 +50,6 @@ function filterData(searchTerms, data) {
found = result.text ? [...result.text.matchAll(regex)] : [];
if (found.length) {
rank ||= 5;
count += found.length;
}
});

Expand Down

0 comments on commit c156e5e

Please sign in to comment.