Unverified Commit 78a35c37 authored by Dan Nicholson's avatar Dan Nicholson Committed by GitHub

feat: include query parameters in locale redirect (#6132)

* feat: include query parameters in locale redirect * refactor: code cleanup --------- Co-authored-by: 's avatarNicolas Giard <github@ngpixel.com>
parent 26dcc007
......@@ -4,6 +4,7 @@ const pageHelper = require('../helpers/page')
const _ = require('lodash')
const CleanCSS = require('clean-css')
const moment = require('moment')
const qs = require('querystring')
/* global WIKI */
......@@ -420,7 +421,8 @@ router.get('/*', async (req, res, next) => {
if (isPage) {
if (WIKI.config.lang.namespacing && !pageArgs.explicitLocale) {
return res.redirect(`/${pageArgs.locale}/${pageArgs.path}`)
const query = !_.isEmpty(req.query) ? `?${qs.stringify(req.query)}` : ''
return res.redirect(`/${pageArgs.locale}/${pageArgs.path}${query}`)
}
req.i18n.changeLanguage(pageArgs.locale)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment