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() {
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() {

Loading…
Cancel
Save