From 80336868dc5863ff2d946a2a50319f77651ecfc4 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 8 May 2024 12:52:42 +0200 Subject: [PATCH] feat: refs #6891 improve useRedirect --- src/composables/useRedirect.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/composables/useRedirect.js b/src/composables/useRedirect.js index 94ca5d0cb5..0666a245fb 100644 --- a/src/composables/useRedirect.js +++ b/src/composables/useRedirect.js @@ -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 };