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