expect(() => router.resolve({ name: 'r2', params: {} })).not.toThrow()
})
+ it('can redirect to a star route when encoding the param', () => {
+ const history = createMemoryHistory()
+ const router = createRouter({
+ history,
+ routes: [
+ { name: 'notfound', path: '/:path(.*)+', component: components.Home },
+ ],
+ })
+ let path = 'not/found%2Fha'
+ let href = '/' + path
+ expect(router.resolve(href)).toMatchObject({
+ name: 'notfound',
+ fullPath: href,
+ path: href,
+ href: href,
+ })
+ expect(
+ router.resolve({
+ name: 'notfound',
+ params: {
+ path: path
+ .split('/')
+ // we need to provide the value unencoded
+ .map(segment => segment.replace('%2F', '/')),
+ },
+ })
+ ).toMatchObject({
+ name: 'notfound',
+ fullPath: href,
+ path: href,
+ href: href,
+ })
+ })
+
describe('Warnings', () => {
mockWarn()
export interface ScrollPositionElement {
/**
- * A simple _id_ selector with a leading `#` or a valid CSS selector **not starting** with a `#`.
+ * A valid CSS selector.
+ *
* @example
* Here are a few examples:
*
if ('scrollBehavior' in document.documentElement.style)
window.scrollTo(scrollToOptions)
- else window.scrollTo(scrollToOptions.left || 0, scrollToOptions.top || 0)
+ else {
+ // TODO: pass the current value instead of 0 using computeScroll
+ window.scrollTo(scrollToOptions.left || 0, scrollToOptions.top || 0)
+ }
}
export function getScrollKey(path: string, delta: number): string {
* ScrollBehavior instance used by the router to compute and restore the scroll
* position when navigating.
*/
-// export interface ScrollHandler<T> {
-// compute(): T
-// scroll(position: T): void
+// export interface ScrollHandler<ScrollPositionEntry extends HistoryStateValue, ScrollPosition extends ScrollPositionEntry> {
+// // returns a scroll position that can be saved in history
+// compute(): ScrollPositionEntry
+// // can take an extended ScrollPositionEntry
+// scroll(position: ScrollPosition): void
// }
// export const scrollHandler: ScrollHandler<ScrollPosition> = {