]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat: use existing params
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 16 Apr 2019 11:04:31 +0000 (13:04 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 16 Apr 2019 11:04:31 +0000 (13:04 +0200)
__tests__/matcher.spec.js
src/matcher.ts

index e38de67e4076d40c7a007662a33b321b0c62d0c7..fe7717e7568b83b806bd644fb330d70ac92aa4fe 100644 (file)
@@ -113,6 +113,23 @@ describe('Router Matcher', () => {
           }
         )
       })
+
+      it('keep params if not provided', () => {
+        assertRecordMatch(
+          { path: '/users/:id/m/:role', name: 'UserEdit', component },
+          {},
+          {
+            name: 'UserEdit',
+            path: '/users/ed/m/user',
+            params: { id: 'ed', role: 'user' },
+          },
+          {
+            path: '/users/ed/m/user',
+            name: 'UserEdit',
+            params: { id: 'ed', role: 'user' },
+          }
+        )
+      })
     })
   })
 })
index f49d0426f0f5b4f54ae36438e724a3fe28c0f9a9..00d0fd8f1a633e6595868c84dc3dc4785c5ac487 100644 (file)
@@ -105,10 +105,12 @@ export class RouterMatcher {
 
     if (!matcher) throw new NoRouteMatchError(currentLocation, location)
 
+    let params = location.params ? location.params : currentLocation.params
+
     return {
       name: currentLocation.name,
-      path: matcher.resolve(location.params),
-      params: location.params || {},
+      path: matcher.resolve(params),
+      params,
     }
   }
 }