2018-07-12 16:35:35 +03:00
|
|
|
const urlService = require('../../services/url');
|
2017-03-14 19:03:30 +03:00
|
|
|
|
|
|
|
function redirectAdminUrls(req, res, next) {
|
2018-07-12 16:35:35 +03:00
|
|
|
const subdir = urlService.utils.getSubdir(),
|
|
|
|
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) {
|
2017-12-11 21:14:05 +03:00
|
|
|
return res.redirect(urlService.utils.urlJoin(urlService.utils.urlFor('admin'), '#', ghostPathMatch[1]));
|
2017-03-14 19:03:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
redirectAdminUrls
|
|
|
|
];
|