Nuxt/test/fixtures/spa/middleware/middleware.js
2024-06-14 12:37:32 +01:00

14 lines
327 B
JavaScript

export default function ({ route, redirect }) {
const redirectPathRegexp = /^\/redirect(\d+)$/
const match = route.path.match(redirectPathRegexp)
if (match) {
const number = parseInt(match[1])
if (number === 1) {
redirect('/redirect-done')
} else {
redirect(`/redirect${number - 1}`)
}
}
}