0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Fixed entry controller to handle v2 and v0.1 url response

refs #9866

- v2 returns absolute urls
- v0.1 returns relative urls
- this is a little ugly, but don't know how else to solve currently
This commit is contained in:
kirrg001 2018-10-17 09:24:01 +02:00 committed by Katharina Irrgang
parent 640290c31b
commit 15f6c2421c

View file

@ -63,12 +63,15 @@ module.exports = function entryController(req, res, next) {
* @NOTE:
*
* Ensure we redirect to the correct post url including subdirectory.
*
* @NOTE:
* This file is used for v0.1 and v2. v0.1 returns relative urls, v2 returns absolute urls.
*/
if (post.url !== req.path) {
if (urlService.utils.absoluteToRelative(post.url, {withoutSubdirectory: true}) !== req.path) {
debug('redirect');
return urlService.utils.redirect301(res, url.format({
pathname: urlService.utils.createUrl(post.url, false, false, true),
pathname: url.parse(post.url).pathname,
search: url.parse(req.originalUrl).search
}));
}