diff --git a/src/composables/useRedirect.js b/src/composables/useRedirect.js index 0666a245fb..57233bea00 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 }); };