c2e47f89ba
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
18 lines
442 B
JavaScript
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
|
|
];
|