2019-06-18 15:13:55 +02:00
|
|
|
const urlUtils = require('../../lib/url-utils');
|
2017-03-14 16:03:30 +00:00
|
|
|
|
|
|
|
function redirectAdminUrls(req, res, next) {
|
2019-06-18 15:13:55 +02:00
|
|
|
const subdir = urlUtils.getSubdir(),
|
2018-07-12 09:35:35 -04:00
|
|
|
ghostPathRegex = new RegExp(`^${subdir}/ghost/(.+)`),
|
2017-06-27 03:08:59 -04:00
|
|
|
ghostPathMatch = req.originalUrl.match(ghostPathRegex);
|
|
|
|
|
2017-03-14 16:03:30 +00:00
|
|
|
if (ghostPathMatch) {
|
2019-06-18 15:13:55 +02:00
|
|
|
return res.redirect(urlUtils.urlJoin(urlUtils.urlFor('admin'), '#', ghostPathMatch[1]));
|
2017-03-14 16:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
redirectAdminUrls
|
|
|
|
];
|