Ghost/core/server/web/admin/middleware.js
Vikas Potluri 1bd8c18a16
Moved core/server/lib/url-utils to core/shared/url-utils (#11856)
* moved url-utils from server to shared
* updated imports of url-utils
2020-05-28 11:57:02 +01:00

18 lines
462 B
JavaScript

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
];