Skip to content

Commit

Permalink
feat: include query parameters in locale redirect (#6132)
Browse files Browse the repository at this point in the history
* feat: include query parameters in locale redirect

* refactor: code cleanup

---------

Co-authored-by: Nicolas Giard <[email protected]>
  • Loading branch information
dbnicholson and NGPixel authored Feb 17, 2023
1 parent 26dcc00 commit 78a35c3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/controllers/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 78a35c3

Please sign in to comment.