mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
parent
dedc5d9239
commit
30861fbab8
1 changed files with 19 additions and 1 deletions
|
@ -428,9 +428,27 @@ requestHandler = function (apiMethod) {
|
||||||
var options = _.extend(req.body, req.query, req.params),
|
var options = _.extend(req.body, req.query, req.params),
|
||||||
apiContext = {
|
apiContext = {
|
||||||
user: req.session && req.session.user
|
user: req.session && req.session.user
|
||||||
};
|
},
|
||||||
|
root = ghost.blogGlobals().path === '/' ? '' : ghost.blogGlobals().path,
|
||||||
|
postRouteIndex,
|
||||||
|
i;
|
||||||
|
|
||||||
|
// If permalinks have changed, find old post route
|
||||||
|
if (req.body.permalinks && req.body.permalinks !== ghost.settings('permalinks')) {
|
||||||
|
for (i = 0; i < req.app.routes.get.length; i += 1) {
|
||||||
|
if (req.app.routes.get[i].path === root + ghost.settings('permalinks')) {
|
||||||
|
postRouteIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return apiMethod.call(apiContext, options).then(function (result) {
|
return apiMethod.call(apiContext, options).then(function (result) {
|
||||||
|
// Reload post route
|
||||||
|
if (postRouteIndex) {
|
||||||
|
req.app.get(ghost.settings('permalinks'), req.app.routes.get.splice(postRouteIndex, 1)[0].callbacks);
|
||||||
|
}
|
||||||
|
|
||||||
invalidateCache(req, res, result);
|
invalidateCache(req, res, result);
|
||||||
res.json(result || {});
|
res.json(result || {});
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue