Skip to content

Commit

Permalink
Use url.parse to support query parms with localeSubpaths
Browse files Browse the repository at this point in the history
  • Loading branch information
isaachinman committed Dec 12, 2018
1 parent b9ece25 commit cb10d37
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/middlewares/next-i18next-middleware.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import i18nextMiddleware from 'i18next-express-middleware'
import { forceTrailingSlash, lngPathDetector } from 'utils'
import { parse } from 'url'

export default function (nexti18next, app, server) {

Expand All @@ -13,7 +14,8 @@ export default function (nexti18next, app, server) {
server.get(/^\/(?!_next|static).*$/, lngPathDetector)
server.get(`/:lng(${allLanguages.join('|')})/*`, (req, res) => {
const { lng } = req.params
app.render(req, res, req.url.replace(`/${lng}`, ''), { lng })
const url = parse(req.url).pathname
app.render(req, res, url.replace(`/${lng}`, ''), { lng })
})
}
}

0 comments on commit cb10d37

Please sign in to comment.