|
|
@@ -563,9 +563,11 @@ module.exports = function(crowi, app) {
|
|
|
* redirector
|
|
|
*/
|
|
|
async function redirector(req, res, next, path) {
|
|
|
- const pages = await Page.findByPathAndViewerV5(path, req.user);
|
|
|
- const { redirectFrom } = req.query;
|
|
|
- const query = redirectFrom == null ? '' : `?redirectFrom=${redirectFrom}`;
|
|
|
+ const pages = await Page.findByPathAndViewer(path, req.user, null, false);
|
|
|
+ let query = '';
|
|
|
+ Object.entries(req.query).forEach(([key, value], i) => {
|
|
|
+ query += i === 0 ? `?${key}=${value}` : `&${key}=${value}`;
|
|
|
+ });
|
|
|
|
|
|
if (pages.length >= 2) {
|
|
|
// TODO: return res.render('layout-growi/select_same_path_page', renderVars);
|
|
|
@@ -574,7 +576,7 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
|
|
|
|
if (pages.length === 1) {
|
|
|
- return res.redirect(`/${pages[0]._id}${query}`);
|
|
|
+ return res.safeRedirect(`/${pages[0]._id}${query}`);
|
|
|
}
|
|
|
|
|
|
return next(); // to page.notFound
|