From 002d4b4e23aa94a40c35d068115bdb8d1837c7ce Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 14 Jun 2013 15:49:48 -0400 Subject: [PATCH] Fix for using non-ascii category name as a link in top_menu --- .../javascripts/discourse/models/nav_item.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/models/nav_item.js b/app/assets/javascripts/discourse/models/nav_item.js index ead576286..a379fe592 100644 --- a/app/assets/javascripts/discourse/models/nav_item.js +++ b/app/assets/javascripts/discourse/models/nav_item.js @@ -20,12 +20,23 @@ Discourse.NavItem = Discourse.Model.extend({ return split[0] === 'category' ? split[1] : null; }.property('name'), + categorySlug: function() { + var split = this.get('name').split('/'); + if (split[0] === 'category' && split[1]) { + var cat = Discourse.Site.instance().categories.findProperty('name', split[1]); + return cat ? Discourse.Category.slugFor(cat) : null; + } + return null; + }.property('name'), + // href from this item href: function() { - var name = this.get('name'), - href = Discourse.getURL("/") + name.replace(' ', '-'); - if (name === 'category') href += "/" + this.get('categoryName'); - return href; + var name = this.get('name'); + if( name.split('/')[0] === 'category' ) { + return Discourse.getURL("/") + 'category/' + this.get('categorySlug'); + } else { + return Discourse.getURL("/") + name.replace(' ', '-'); + } }.property('name'), count: function() {