mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): encode location header in navigateTo (#26712)
This commit is contained in:
parent
a7425d30a7
commit
30e27f48d1
@ -169,7 +169,7 @@ export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: Na
|
||||
nuxtApp.ssrContext!._renderResponse = {
|
||||
statusCode: sanitizeStatusCode(options?.redirectCode || 302, 302),
|
||||
body: `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${encodedLoc}"></head></html>`,
|
||||
headers: { location },
|
||||
headers: { location: encodeURI(location) },
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
@ -900,6 +900,12 @@ describe('navigate', () => {
|
||||
|
||||
expect(status).toEqual(404)
|
||||
})
|
||||
|
||||
it('expect to redirect with encoding', async () => {
|
||||
const { status } = await fetch('/redirect-with-encode', { redirect: 'manual' })
|
||||
|
||||
expect(status).toEqual(302)
|
||||
})
|
||||
})
|
||||
|
||||
describe('preserves current instance', () => {
|
||||
|
9
test/fixtures/basic/pages/redirect-with-encode.vue
vendored
Normal file
9
test/fixtures/basic/pages/redirect-with-encode.vue
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
oh no !
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
await navigateTo('/cœur')
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user