Skip to content

Node.js based forum software built for the modern web

feat: #7467, pass query params when redirecting to posts

Barış Soner Uşaklı480a64aaa7a8
diff --git a/src/controllers/posts.js b/src/controllers/posts.js
index f8d445d1a4..20b0ae4292 100644
--- a/src/controllers/posts.js
+++ b/src/controllers/posts.js
@@ -1,5 +1,7 @@
'use strict';
+const querystring = require('querystring');
+
const posts = require('../posts');
const privileges = require('../privileges');
const helpers = require('./helpers');
@@ -22,7 +24,9 @@ postsController.redirectToPost = async function (req, res, next) {
if (!canRead) {
return helpers.notAllowed(req, res);
}
- helpers.redirect(res, path);
+
+ const qs = querystring.stringify(req.query);
+ helpers.redirect(res, qs ? path + '?' + qs : path);
};
postsController.getRecentPosts = async function (req, res) {
diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js
index ab353cd923..6536af0d63 100644
--- a/test/mocks/databasemock.js
+++ b/test/mocks/databasemock.js
@@ -169,6 +169,7 @@ async function setupMockDefaults() {
meta.config.postDelay = 0;
meta.config.initialPostDelay = 0;
meta.config.newbiePostDelay = 0;
+ meta.config.autoDetectLang = 0;
await enableDefaultPlugins();