2020-05-28 05:57:02 -05:00
|
|
|
const urlUtils = require('../../../shared/url-utils');
|
2017-03-14 16:03:30 +00:00
|
|
|
|
|
|
|
function redirectAdminUrls(req, res, next) {
|
2020-04-29 16:44:27 +01:00
|
|
|
const subdir = urlUtils.getSubdir();
|
|
|
|
const ghostPathRegex = new RegExp(`^${subdir}/ghost/(.+)`);
|
|
|
|
const ghostPathMatch = req.originalUrl.match(ghostPathRegex);
|
2017-06-27 03:08:59 -04:00
|
|
|
|
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
|
|
|
|
];
|