0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/server/web/admin/middleware.js
2018-07-12 15:35:35 +02:00

17 lines
477 B
JavaScript

const urlService = require('../../services/url');
function redirectAdminUrls(req, res, next) {
const subdir = urlService.utils.getSubdir(),
ghostPathRegex = new RegExp(`^${subdir}/ghost/(.+)`),
ghostPathMatch = req.originalUrl.match(ghostPathRegex);
if (ghostPathMatch) {
return res.redirect(urlService.utils.urlJoin(urlService.utils.urlFor('admin'), '#', ghostPathMatch[1]));
}
next();
}
module.exports = [
redirectAdminUrls
];