2017-12-11 21:14:05 +03:00
|
|
|
var urlService = require('../../services/url');
|
2017-03-14 19:03:30 +03:00
|
|
|
|
|
|
|
function redirectAdminUrls(req, res, next) {
|
2017-12-11 21:14:05 +03:00
|
|
|
var subdir = urlService.utils.getSubdir(),
|
2017-06-27 10:08:59 +03:00
|
|
|
ghostPathRegex = new RegExp('^' + subdir + '/ghost/(.+)'),
|
|
|
|
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
|
|
|
|
];
|