fix: normalize route path in profile middleware
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user