From 54de10144278e07115801a9d9ab51d7a3deb88d5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 8 May 2024 13:00:54 +0200 Subject: [PATCH] feat: refs #6891 improve useRedirect --- src/composables/useRedirect.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/composables/useRedirect.js b/src/composables/useRedirect.js index 0666a245f..57233bea0 100644 --- a/src/composables/useRedirect.js +++ b/src/composables/useRedirect.js @@ -13,9 +13,10 @@ export default function useRedirect() { const { matched: matches } = router.currentRoute.value; const { path } = matches.at(-1); - let to = path.replace(/:id.*/, ''); - - if (data.length === 1) to = path.replace(/\/(list|-list|:id)/, `/${data[0].id}`); + const to = + data.length === 1 + ? path.replace(/\/(list|-list|:id)/, `/${data[0].id}`) + : path.replace(/:id.*/, ''); router.push({ path: to }); };