search fix prevent crash if search term is invalid regex

This commit is contained in:
barisusakli
2015-04-23 17:58:28 -04:00
parent e5928f330e
commit 03b0d282f1
2 changed files with 15 additions and 17 deletions

View File

@@ -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;
}
});
}