feat: refs #7925 wip redirect not found

This commit is contained in:
Jorge Penadés 2024-11-07 14:34:33 +01:00
parent f7de0f09de
commit c64f87533d
1 changed files with 8 additions and 9 deletions

View File

@ -262,15 +262,14 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
const { path } = matches.at(-1);
const rowsNumber = store.data.length;
if (path.includes(':id') && !rowsNumber)
return router.push({
name: 'NotFound',
});
const to =
rowsNumber === 1
? path.replace(/\/(list|:id)|-list/, `/${store.data[0].id}`)
: path.replace(/:id.*/, '');
let to;
if (path.includes(':id') && !rowsNumber) {
return router.push({ name: 'NotFound' });
} else if (rowsNumber === 1) {
to = path.replace(/\/(list|:id)|-list/, `/${store.data[0].id}`);
} else {
to = path.replace(/:id.*/, '');
}
if (route.path != to) {
const pushUrl = { path: to };