mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-17 13:31:39 +03:00
4265afe580
refs #9178 - we have to take care that we don't end up in circular dependencies - e.g. API requires UrlService and UrlService needs to require the API (for requesting data) - update the references - we would like to get rid of the utils folder, this is/was the most complicated change
18 lines
478 B
JavaScript
18 lines
478 B
JavaScript
var urlService = require('../../services/url');
|
|
|
|
function redirectAdminUrls(req, res, next) {
|
|
var 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
|
|
];
|