From 01dc9bd83448d1d79e5c6693a0769a28d04449d4 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Mon, 16 Feb 2015 19:06:35 +0000 Subject: [PATCH] Ensure internal nav items have a trailing slash refs #4535 - all internal urls in ghost have a trailing slash, missing it out will cause nav-current to not work --- core/client/controllers/settings/navigation.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/client/controllers/settings/navigation.js b/core/client/controllers/settings/navigation.js index d68ad0ff7f..53f971c8d7 100644 --- a/core/client/controllers/settings/navigation.js +++ b/core/client/controllers/settings/navigation.js @@ -125,13 +125,16 @@ NavigationController = Ember.Controller.extend({ url = item.get('url').trim(); order = item.get('order'); + // is this an internal URL? match = url.match(blogUrlRegex); if (match) { - if (match[1] === '') { - url = '/'; - } else { - url = match[1]; + url = match[1]; + + // if the last char is not a slash, then add one, + // this also handles the empty case for the homepage + if (url[url.length - 1] !== '/') { + url += '/'; } } else if (!validator.isURL(url) && url !== '' && url[0] !== '/') { url = '/' + url;