fix: normalize route path in profile middleware

This commit is contained in:
Matthieu
2025-09-18 08:35:18 +02:00
parent 95c1e66520
commit 4787c1ea8f

View File

@@ -4,9 +4,10 @@ export default defineNuxtRouteMiddleware(async (to) => {
const { ensureSession, activeProfile } = useProfileSession()
await ensureSession()
const path = to.path || ''
const routeName = typeof to.name === 'string' ? to.name : ''
const isProfilesRoute = path.startsWith('/profiles') || routeName.startsWith('profiles')
const rawPath = to?.path ?? ''
const normalizedPath = rawPath.startsWith('/') ? rawPath : `/${rawPath}`
const routeName = typeof to?.name === 'string' ? to.name : ''
const isProfilesRoute = normalizedPath.startsWith('/profiles') || routeName.startsWith('profiles')
if (!activeProfile.value && !isProfilesRoute) {
return navigateTo('/profiles')