fix: ensure profile middleware respects full path
This commit is contained in:
@@ -6,10 +6,16 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
||||
|
||||
const rawPath = to?.path ?? ''
|
||||
const normalizedPath = rawPath.startsWith('/') ? rawPath : `/${rawPath}`
|
||||
const fullPath = to?.fullPath ?? normalizedPath
|
||||
const routeName = typeof to?.name === 'string' ? to.name : ''
|
||||
const isProfilesRoute = normalizedPath.startsWith('/profiles') || routeName.startsWith('profiles')
|
||||
const isProfilesRoute =
|
||||
normalizedPath.startsWith('/profiles') ||
|
||||
fullPath.startsWith('/profiles') ||
|
||||
routeName.startsWith('profiles')
|
||||
|
||||
if (!activeProfile.value && !isProfilesRoute) {
|
||||
return navigateTo('/profiles')
|
||||
if (!normalizedPath.startsWith('/profiles')) {
|
||||
return navigateTo('/profiles')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user