fix(server): allow rendering urls with unicode characters (#4512)

This commit is contained in:
Dmitry Molotkov 2018-12-10 19:48:23 +03:00 committed by Xin Du (Clark)
parent b47a993429
commit c3128eaced
2 changed files with 3 additions and 2 deletions

View File

@ -7,7 +7,7 @@ import { getContext } from '@nuxt/common'
export default ({ options, nuxt, renderRoute, resources }) => async function nuxtMiddleware(req, res, next) { export default ({ options, nuxt, renderRoute, resources }) => async function nuxtMiddleware(req, res, next) {
// Get context // Get context
const context = getContext(req, res) const context = getContext(req, res)
const url = req.url const url = decodeURI(req.url)
res.statusCode = 200 res.statusCode = 200
try { try {

View File

@ -324,7 +324,8 @@ describe('basic ssr', () => {
}) })
test('/тест雨 (test non ascii route)', async () => { test('/тест雨 (test non ascii route)', async () => {
const { html } = await nuxt.server.renderRoute('/тест雨') const window = await nuxt.server.renderAndGetWindow(url('/тест雨'))
const html = window.document.body.innerHTML
expect(html).toMatch('Hello unicode') expect(html).toMatch('Hello unicode')
}) })