0
0
Fork 0

feat: refs #6891 improve useRedirect

This commit is contained in:
Jorge Penadés 2024-05-08 12:52:42 +02:00
parent 7b370e6b93
commit 80336868dc
1 changed files with 4 additions and 5 deletions

View File

@ -13,12 +13,11 @@ export default function useRedirect() {
const { matched: matches } = router.currentRoute.value;
const { path } = matches.at(-1);
if (data.length === 1)
return router.push({
path: path.replace(/\/(list|-list|:id)/, `/${data[0].id}`),
});
let to = path.replace(/:id.*/, '');
router.push({ path: path.replace(/:id.*/, '') });
if (data.length === 1) to = path.replace(/\/(list|-list|:id)/, `/${data[0].id}`);
router.push({ path: to });
};
return { navigate };