mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
search fix prevent crash if search term is invalid regex
This commit is contained in:
@@ -187,19 +187,13 @@ app.cacheBuster = null;
|
||||
};
|
||||
|
||||
function highlightNavigationLink() {
|
||||
var path = window.location.pathname,
|
||||
parts = path.split('/'),
|
||||
active = parts[parts.length - 1];
|
||||
|
||||
var path = window.location.pathname;
|
||||
$('#main-nav li').removeClass('active');
|
||||
if (active) {
|
||||
if (path) {
|
||||
$('#main-nav li a').each(function () {
|
||||
var href = $(this).attr('href');
|
||||
if (active === "sort-posts" || active === "sort-reputation" || active === "search" || active === "latest" || active === "online") {
|
||||
active = 'users';
|
||||
}
|
||||
|
||||
if (href && href.match(active)) {
|
||||
if (href && path.startsWith(href)) {
|
||||
$(this.parentNode).addClass('active');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var regexStr = searchQuery.trim().split(' ').join('|');
|
||||
var regex = new RegExp('(' + regexStr + ')', 'gi');
|
||||
|
||||
@@ -125,6 +126,9 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco
|
||||
var text = result.html().replace(regex, '<strong>$1</strong>');
|
||||
result.html(text).find('img').addClass('img-responsive');
|
||||
});
|
||||
} catch(e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function handleSavePreferences() {
|
||||
|
||||
Reference in New Issue
Block a user