search fix prevent crash if search term is invalid regex

v1.18.x
barisusakli 10 years ago
parent e5928f330e
commit 03b0d282f1

@ -187,19 +187,13 @@ app.cacheBuster = null;
}; };
function highlightNavigationLink() { function highlightNavigationLink() {
var path = window.location.pathname, var path = window.location.pathname;
parts = path.split('/'),
active = parts[parts.length - 1];
$('#main-nav li').removeClass('active'); $('#main-nav li').removeClass('active');
if (active) { if (path) {
$('#main-nav li a').each(function () { $('#main-nav li a').each(function () {
var href = $(this).attr('href'); 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'); $(this.parentNode).addClass('active');
return false; return false;
} }

@ -117,6 +117,7 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco
return; return;
} }
try {
var regexStr = searchQuery.trim().split(' ').join('|'); var regexStr = searchQuery.trim().split(' ').join('|');
var regex = new RegExp('(' + regexStr + ')', 'gi'); 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>'); var text = result.html().replace(regex, '<strong>$1</strong>');
result.html(text).find('img').addClass('img-responsive'); result.html(text).find('img').addClass('img-responsive');
}); });
} catch(e) {
return;
}
} }
function handleSavePreferences() { function handleSavePreferences() {

Loading…
Cancel
Save