Fix VueRouterCompat redirect handling and initial URL update
What does this MR do and why?
Fixes two related issues in the Vue Router 3→4 compatibility layer (VueRouterCompat):
-
Child catch-all redirects not matching empty paths: In Vue Router 3, a child
*route with a redirect would match when the parent path was visited with no trailing child segment (e.g., visiting/would match*and redirect). Vue Router 4's:pathMatch(.*)*does NOT match the empty string in child routes. This MR adds an empty-path sibling route with the same redirect to preserve Vue Router 3 behavior. -
Browser URL not updating on initial redirect:
VueRouterCompatsynchronously setsrouter.currentRoute.valueto the redirect-resolved route so that components reading$routeindata()see the correct value immediately. However, this prevents Vue Router 4'sinstall()from running its initial async navigation (it checkscurrentRoute.value === START_LOCATION_NORMALIZEDand skips if already changed). That initial navigation is what updates the browser URL viahistory.replace(). This MR adds ahistory.replace(resolved.fullPath)call after following redirects to ensure the browser URL reflects the final destination.
These issues were discovered while enabling Vue 3 compat mode for the Compliance Center, where visiting /groups/:group/-/security/compliance_dashboard should redirect to .../compliance_dashboard/dashboard but the URL was not being updated.
References
Related to the Vue 3 migration effort.
How to set up and validate locally
- Run Vue 3 compat tests:
VUE_VERSION=3 yarn jest spec/frontend/lib/utils/vue3compat/vue_router_spec.js --no-coverage - Run Vue 2 tests (should also pass):
yarn jest spec/frontend/lib/utils/vue3compat/vue_router_spec.js --no-coverage - All 26 tests should pass in both modes.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.