From a94e2a87fb759e7b7daed2d0304c1199dbc7afd1 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 7 Dec 2020 15:17:31 -0500 Subject: [PATCH] fix(vue): query strings are now correctly handled when navigating back (#22615) resolves #22517 --- packages/vue-router/src/router.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/vue-router/src/router.ts b/packages/vue-router/src/router.ts index ce467cf68a..d67b445536 100644 --- a/packages/vue-router/src/router.ts +++ b/packages/vue-router/src/router.ts @@ -1,4 +1,5 @@ import { + parseQuery, Router, RouteLocationNormalized, NavigationFailure @@ -90,7 +91,7 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) => if (routeInfo.lastPathname === routeInfo.pushedByRoute) { router.back(); } else { - router.replace(prevInfo.pathname + (prevInfo.search || '')); + router.replace({ path: prevInfo.pathname, query: parseQuery(prevInfo.search) }); } } else { handleNavigate(defaultHref, 'pop', 'back'); @@ -236,7 +237,7 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) => const newRouteInfo = { ...routeInfo }; newRouteInfo.pathname = originalHref; incomingRouteParams = { ...newRouteInfo, routerAction: 'pop', routerDirection: 'back' }; - router.push(newRouteInfo.pathname + (newRouteInfo.search || '')); + router.push({ path: newRouteInfo.pathname, query: parseQuery(newRouteInfo.search) }); } } @@ -245,8 +246,6 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) => const [pathname] = path.split('?'); if (routeInfo) { - const search = (routeInfo.search) ? `?${routeInfo.search}` : ''; - incomingRouteParams = { ...incomingRouteParams, routerAction: 'push', @@ -262,9 +261,9 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) => * tab you are on. */ if (routeInfo.pathname === pathname) { - router.push(routeInfo.pathname + search); + router.push({ path: routeInfo.pathname, query: parseQuery(routeInfo.search) }); } else { - router.push(pathname + search); + router.push({ path: pathname, query: parseQuery(routeInfo.search) }); } } else {