0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/core/server/web/admin/middleware.js

18 lines
462 B
JavaScript
Raw Normal View History

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