Ghost/core/server/admin/middleware.js
Patrick Kim c2e47f89ba 🐛 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
2017-06-27 09:08:59 +02:00

18 lines
442 B
JavaScript

var utils = require('../utils');
function redirectAdminUrls(req, res, next) {
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]));
}
next();
}
module.exports = [
redirectAdminUrls
];