From 4b1ece9f01f982facb7febfa8e3a439590e72f85 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Mon, 9 Mar 2015 16:24:51 +0100 Subject: [PATCH] Ensure correct url in ghost_head Closes #4967 - Previously, an additional `/` was added to the prev/next links. This removes the additional slash. --- core/server/helpers/ghost_head.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/server/helpers/ghost_head.js b/core/server/helpers/ghost_head.js index e8dc056295..efccc93bb2 100644 --- a/core/server/helpers/ghost_head.js +++ b/core/server/helpers/ghost_head.js @@ -32,6 +32,7 @@ ghost_head = function (options) { majorMinor = /^(\d+\.)?(\d+)/, trimmedVersion = this.version, trimmedUrlpattern = /.+(?=\/page\/\d*\/)/, + tagOrAuthorPattern = /\/(tag)|(author)\//, trimmedUrl, next, prev, tags, ops = [], structuredData, @@ -76,12 +77,16 @@ ghost_head = function (options) { trimmedUrl = self.relativeUrl.match(trimmedUrlpattern); if (self.pagination.prev) { prev = (self.pagination.prev > 1 ? prev = '/page/' + self.pagination.prev + '/' : prev = '/'); - prev = (trimmedUrl) ? '/' + trimmedUrl + prev : prev; + prev = (trimmedUrl) ? trimmedUrl + prev : prev; head.push(''); } if (self.pagination.next) { next = '/page/' + self.pagination.next + '/'; - next = (trimmedUrl) ? '/' + trimmedUrl + next : next; + if (trimmedUrl) { + next = trimmedUrl + next; + } else if (tagOrAuthorPattern.test(self.relativeUrl)) { + next = self.relativeUrl.slice(0, -1) + next; + } head.push(''); } }