Skip to content

Commit

Permalink
fix: multiword match highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Sep 23, 2020
1 parent d38c872 commit f8ef380
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions public/src/client/search.js
Expand Up @@ -139,8 +139,10 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
return;
}
searchQuery = utils.escapeHTML(searchQuery.replace(/^"/, '').replace(/"$/, '').trim());
var regexStr = searchQuery.split(' ').join('|');
var regex = new RegExp('(' + utils.escapeRegexChars(regexStr) + ')', 'gi');
var regexStr = searchQuery.split(' ')
.map(function (word) { return utils.escapeRegexChars(word); })
.join('|');
var regex = new RegExp('(' + regexStr + ')', 'gi');

$('.search-result-text p, .search-result-text h4').each(function () {
var result = $(this);
Expand Down

0 comments on commit f8ef380

Please sign in to comment.