🐛 Modify regex to allow subdir/ghost urls. (#8627)

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
This commit is contained in:
Patrick Kim 2017-06-27 03:08:59 -04:00 committed by Katharina Irrgang
parent 21d7791eae
commit c2e47f89ba

View File

@ -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]));
}