feat: include query parameters in locale redirect (#6132)
* feat: include query parameters in locale redirect * refactor: code cleanup --------- Co-authored-by: Nicolas Giard <github@ngpixel.com>
This commit is contained in:
parent
26dcc007e7
commit
78a35c377c
@ -4,6 +4,7 @@ const pageHelper = require('../helpers/page')
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const CleanCSS = require('clean-css')
|
const CleanCSS = require('clean-css')
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
|
const qs = require('querystring')
|
||||||
|
|
||||||
/* global WIKI */
|
/* global WIKI */
|
||||||
|
|
||||||
@ -420,7 +421,8 @@ router.get('/*', async (req, res, next) => {
|
|||||||
|
|
||||||
if (isPage) {
|
if (isPage) {
|
||||||
if (WIKI.config.lang.namespacing && !pageArgs.explicitLocale) {
|
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)
|
req.i18n.changeLanguage(pageArgs.locale)
|
||||||
|
Loading…
Reference in New Issue
Block a user