mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
Added tests to confirm `buildHeader` is used and `/api` works
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
c839d1cbc0
commit
11b9cb7688
@@ -36,7 +36,7 @@ function getRouteAllowUserHomePage(uid, next) {
|
||||
pubsub.on('config:update', configUpdated);
|
||||
configUpdated();
|
||||
|
||||
module.exports = function (req, res, next) {
|
||||
function rewrite(req, res, next) {
|
||||
if (req.path !== '/' && req.path !== '/api/' && req.path !== '/api') {
|
||||
return next();
|
||||
}
|
||||
@@ -48,15 +48,26 @@ module.exports = function (req, res, next) {
|
||||
|
||||
var hook = 'action:homepage.get:' + route;
|
||||
|
||||
if (plugins.hasListeners(hook)) {
|
||||
return plugins.fireHook(hook, {
|
||||
req: req,
|
||||
res: res,
|
||||
next: next,
|
||||
});
|
||||
if (!plugins.hasListeners(hook)) {
|
||||
req.url = req.path + (!req.path.endsWith('/') ? '/' : '') + route;
|
||||
} else {
|
||||
res.locals.homePageRoute = route;
|
||||
}
|
||||
|
||||
req.url = req.path + (!req.path.endsWith('/') ? '/' : '') + route;
|
||||
next();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
exports.rewrite = rewrite;
|
||||
|
||||
function pluginHook(req, res, next) {
|
||||
var hook = 'action:homepage.get:' + res.locals.homePageRoute;
|
||||
|
||||
plugins.fireHook(hook, {
|
||||
req: req,
|
||||
res: res,
|
||||
next: next,
|
||||
});
|
||||
}
|
||||
|
||||
exports.pluginHook = pluginHook;
|
||||
|
||||
Reference in New Issue
Block a user