abda6e6338
closes #10773 - The refactoring is a substitute for `urlService.utils` used previously throughout the codebase and now extracted into the separate module in Ghost-SDK - Added url-utils stubbing utility for test suites - Some tests had to be refactored to avoid double mocks (when url's are being reset inside of rested 'describe' groups)
18 lines
452 B
JavaScript
18 lines
452 B
JavaScript
const urlUtils = require('../../lib/url-utils');
|
|
|
|
function redirectAdminUrls(req, res, next) {
|
|
const subdir = urlUtils.getSubdir(),
|
|
ghostPathRegex = new RegExp(`^${subdir}/ghost/(.+)`),
|
|
ghostPathMatch = req.originalUrl.match(ghostPathRegex);
|
|
|
|
if (ghostPathMatch) {
|
|
return res.redirect(urlUtils.urlJoin(urlUtils.urlFor('admin'), '#', ghostPathMatch[1]));
|
|
}
|
|
|
|
next();
|
|
}
|
|
|
|
module.exports = [
|
|
redirectAdminUrls
|
|
];
|