Skip to content

Commit 03a7f9a

Browse files
authored
fix: route resolve loses query parameters (#38)
1 parent e283d90 commit 03a7f9a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/vue-i18n-routing/src/__test__/compatibles.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ describe('localePath', () => {
9797
assert.equal(vm.localePath({ state: { foo: 1 } }), '/en')
9898
await router.push('/ja')
9999
assert.equal(vm.localePath({ state: { foo: 1 } }), '/ja')
100+
101+
// preserve query parameters
102+
assert.equal(vm.localePath({ query: { foo: 1 } }), '/ja?foo=1')
103+
assert.equal(vm.localePath({ path: '/', query: { foo: 1 } }), '/ja?foo=1')
104+
assert.equal(vm.localePath({ name: 'about', query: { foo: 1 } }), '/ja/about?foo=1')
105+
assert.equal(vm.localePath({ path: '/about', query: { foo: 1 } }), '/ja/about?foo=1')
106+
100107
// no define path
101108
assert.equal(vm.localePath('/vue-i18n'), '/ja/vue-i18n')
102109
// no define name

packages/vue-i18n-routing/src/compatibles/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ export function resolve(router: Router | VueRouter, route: any, strategy: Strate
7979
if (_route == null) {
8080
return route
8181
} else {
82-
const _resolevableRoute = assign({}, _route)
83-
_resolevableRoute.path = targetPath
84-
return router.resolve(_resolevableRoute)
82+
const _resolvableRoute = assign({}, route, _route)
83+
_resolvableRoute.path = targetPath
84+
return router.resolve(_resolvableRoute)
8585
}
8686
} else {
8787
return router.resolve(route)

0 commit comments

Comments
 (0)