)
})
+ it('resolves an array of params for a repeatable params', () => {
+ assertRecordMatch(
+ { path: '/a/:p+', name: 'a', components },
+ { name: 'a', params: { p: ['b', 'c', 'd'] } },
+ { name: 'a', path: '/a/b/c/d', params: { p: ['b', 'c', 'd'] } }
+ )
+ })
+
+ it('resolves single params for a repeatable params', () => {
+ assertRecordMatch(
+ { path: '/a/:p+', name: 'a', components },
+ { name: 'a', params: { p: 'b' } },
+ { name: 'a', path: '/a/b', params: { p: 'b' } }
+ )
+ })
+
+ it('keeps repeated params as a single one when provided through path', () => {
+ assertRecordMatch(
+ { path: '/a/:p+', name: 'a', components },
+ { path: '/a/b/c' },
+ // TODO: maybe it should consistently be an array for repeated params
+ { name: 'a', params: { p: 'b/c' } }
+ )
+ })
+
it('resolves a path with multiple params', () => {
assertRecordMatch(
{ path: '/users/:id/:other', name: 'User', components },
],
},
{ path: '/with-data', component: ComponentWithData, name: 'WithData' },
+ { path: '/rep/:a*', component: component, name: 'repeat' },
// { path: /^\/about\/?$/, component },
],
async scrollBehavior(to, from, savedPosition) {
/**
* Transforms a MatcherLocation object into a normalized location
* @param location MatcherLocation to resolve to a url
+ * @param currentLocation MatcherLocationNormalized of the current location
*/
resolve(
location: Readonly<MatcherLocation>,
normalizeQuery,
HistoryLocationNormalized,
START,
+ NavigationDirection,
} from './history/common'
import { RouterMatcher } from './matcher'
import {
export interface RouterOptions {
history: RouterHistory
routes: RouteRecord[]
- // TODO: async version
scrollBehavior?: ScrollBehavior
}
// Maybe we could write the length the first time we do a navigation and use that for direction
// TODO: this doesn't work if the user directly calls window.history.go(-n) with n > 1
// We can override the go method to retrieve the number but not sure if all browsers allow that
- // if (info.direction === NavigationDirection.back) {
- // this.history.forward(false)
- // } else {
- // TODO: go back because we cancelled, then
- // or replace and not discard the rest of history. Check issues, there was one talking about this
- // behaviour, maybe we can do better
- // this.history.back(false)
- // }
+ if (info.direction === NavigationDirection.back) {
+ this.history.forward(false)
+ } else {
+ // TODO: go back because we cancelled, then
+ // or replace and not discard the rest of history. Check issues, there was one talking about this
+ // behaviour, maybe we can do better
+ this.history.back(false)
+ }
} else {
this.triggerError(error, false)
}