search fix prevent crash if search term is invalid regex

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

@ -187,21 +187,15 @@ 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;
return false;
}
});
}

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