mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
fix(vue-app): prevent redirection loop with uri encoded path (#8280)
This commit is contained in:
parent
011b3b4491
commit
e14b7201b4
@ -50,7 +50,7 @@ const createNext = ssrContext => (opts) => {
|
||||
opts.path = urlJoin(routerBase, opts.path)
|
||||
}
|
||||
// Avoid loop redirect
|
||||
if (opts.path === ssrContext.url) {
|
||||
if (decodeURIComponent(opts.path) === ssrContext.url) {
|
||||
ssrContext.redirected = false
|
||||
return
|
||||
}
|
||||
|
@ -319,6 +319,11 @@ describe('basic browser', () => {
|
||||
page.close()
|
||||
})
|
||||
|
||||
test('/redirection/no loop', async () => {
|
||||
const page = await browser.page(url('/redirection/no loop'))
|
||||
expect(await page.$text('h1')).toContain('Redirected page')
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
afterAll(async () => {
|
||||
await nuxt.close()
|
||||
|
18
test/fixtures/basic/pages/redirection/_slug.vue
vendored
Normal file
18
test/fixtures/basic/pages/redirection/_slug.vue
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<h1>
|
||||
Redirected page
|
||||
</h1>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
asyncData ({ redirect, route }) {
|
||||
if (process.server) {
|
||||
// Redirect to the same route
|
||||
redirect(route)
|
||||
}
|
||||
|
||||
return {}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user