From c2e47f89bab1eb558d2fc42cee87098965d7553b Mon Sep 17 00:00:00 2001 From: Patrick Kim Date: Tue, 27 Jun 2017 03:08:59 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Modify=20regex=20to=20allow=20su?= =?UTF-8?q?bdir/ghost=20urls.=20(#8627)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - redirect admin url's if Ghost uses a subdirectory - fixes a bug where reset password and invite links do not route to the right destination --- core/server/admin/middleware.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/server/admin/middleware.js b/core/server/admin/middleware.js index 8485436c9d..d12673dc78 100644 --- a/core/server/admin/middleware.js +++ b/core/server/admin/middleware.js @@ -1,7 +1,10 @@ var utils = require('../utils'); function redirectAdminUrls(req, res, next) { - var ghostPathMatch = req.originalUrl.match(/^\/ghost\/(.+)$/); + var subdir = utils.url.getSubdir(), + ghostPathRegex = new RegExp('^' + subdir + '/ghost/(.+)'), + ghostPathMatch = req.originalUrl.match(ghostPathRegex); + if (ghostPathMatch) { return res.redirect(utils.url.urlJoin(utils.url.urlFor('admin'), '#', ghostPathMatch[1])); }