From 62296818aa19f00e3136d97a7f84f65bd5cab19b Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Mon, 22 Apr 2024 23:11:46 +0200 Subject: [PATCH] fix(nuxt): don't encode location header (#26893) --- packages/nuxt/src/app/composables/router.ts | 3 ++- test/basic.test.ts | 6 ------ test/fixtures/basic/pages/redirect-with-encode.vue | 9 --------- 3 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 test/fixtures/basic/pages/redirect-with-encode.vue diff --git a/packages/nuxt/src/app/composables/router.ts b/packages/nuxt/src/app/composables/router.ts index 65cde55392..072ff76155 100644 --- a/packages/nuxt/src/app/composables/router.ts +++ b/packages/nuxt/src/app/composables/router.ts @@ -169,7 +169,8 @@ export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: Na nuxtApp.ssrContext!._renderResponse = { statusCode: sanitizeStatusCode(options?.redirectCode || 302, 302), body: ``, - headers: { location: encodeURI(location) }, + // do not encode as this would break some modules and some environments + headers: { location }, } return response } diff --git a/test/basic.test.ts b/test/basic.test.ts index d43326254b..13102e7cf0 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -937,12 +937,6 @@ 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', () => { diff --git a/test/fixtures/basic/pages/redirect-with-encode.vue b/test/fixtures/basic/pages/redirect-with-encode.vue deleted file mode 100644 index a59a44d653..0000000000 --- a/test/fixtures/basic/pages/redirect-with-encode.vue +++ /dev/null @@ -1,9 +0,0 @@ - - -