These are technically breaking changes but they fix an inconsistent behavior.
-- Pushing or resolving a non existant named route throws an error instead of navigating to `/` and displaying nothing.
+- Pushing or resolving a non existent named route throws an error instead of navigating to `/` and displaying nothing.
### Missing features
currentRoute: ref(
markNonReactive({
...route,
- // reset the instances everytime
+ // reset the instances every time
matched: route.matched.map(match => ({ ...match, instances: {} })),
})
),
const loc2: RawHistoryLocation = '/bar'
-const normaliezedLoc: HistoryLocationNormalized = {
+const normalizedLoc: HistoryLocationNormalized = {
fullPath: '/foo',
}
-const normaliezedLoc2: HistoryLocationNormalized = {
+const normalizedLoc2: HistoryLocationNormalized = {
fullPath: '/bar',
}
history.push(loc)
history.push(loc2)
history.back()
- expect(history.location).toEqual(normaliezedLoc)
+ expect(history.location).toEqual(normalizedLoc)
history.back()
expect(history.location).toEqual(START)
})
history.back()
expect(history.location).toEqual(START)
history.forward()
- expect(history.location).toEqual(normaliezedLoc)
+ expect(history.location).toEqual(normalizedLoc)
history.forward()
- expect(history.location).toEqual(normaliezedLoc2)
+ expect(history.location).toEqual(normalizedLoc2)
})
it('can push in the middle of the history', () => {
history.back()
expect(history.location).toEqual(START)
history.push(loc2)
- expect(history.location).toEqual(normaliezedLoc2)
+ expect(history.location).toEqual(normalizedLoc2)
// does nothing
history.forward()
- expect(history.location).toEqual(normaliezedLoc2)
+ expect(history.location).toEqual(normalizedLoc2)
})
it('can listen to navigations', () => {
history.push(loc)
history.back()
expect(spy).toHaveBeenCalledTimes(1)
- expect(spy).toHaveBeenCalledWith(START, normaliezedLoc, {
+ expect(spy).toHaveBeenCalledWith(START, normalizedLoc, {
direction: 'back',
distance: -1,
type: 'pop',
})
history.forward()
expect(spy).toHaveBeenCalledTimes(2)
- expect(spy).toHaveBeenLastCalledWith(normaliezedLoc, START, {
+ expect(spy).toHaveBeenLastCalledWith(normalizedLoc, START, {
direction: 'forward',
distance: 1,
type: 'pop',
matchParams('/home', '/', null)
})
- it('allows an empty rooot', () => {
+ it('allows an empty root', () => {
matchParams('', '/', {})
})
matchParams('/a/:a(?:b-([^/]+\\)?)', '/a/b-', {
a: '',
})
+ // non optional
matchParams('/a/:a(?:b-([^/]+\\))', '/a/b-one', {
a: 'one',
})
matchStringify('/:a*/other', {}, '/other')
})
- // end of stringifying urls
+ // end of generating urls
})
})
])
})
- it('puts the slash before optional paramateres', () => {
+ it('puts the slash before optional parameters', () => {
possibleOptions.forEach(options => {
checkPathOrder(['/', ['/:a?', options]])
checkPathOrder(['/', ['/:a*', options]])
])
})
- it('orders repeteable and optional', () => {
+ it('orders repeatable and optional', () => {
possibleOptions.forEach(options => {
checkPathOrder(['/:w', ['/:w?', options]])
checkPathOrder(['/:w?', ['/:w+', options]])
checkPathOrder(['/a/b/c/d/e', '/:k/b/c/d/e', '/:k/b/c/d/:j'])
})
- it('prioritises custom regex', () => {
+ it('prioritizes custom regex', () => {
checkPathOrder(['/:a(\\d+)', '/:a', '/:a(.*)'])
checkPathOrder(['/b-:a(\\d+)', '/b-:a', '/b-:a(.*)'])
})
}
function includesParams(
- outter: RouteLocation['params'],
+ outer: RouteLocation['params'],
inner: RouteLocation['params']
): boolean {
for (let key in inner) {
let innerValue = inner[key]
- let outterValue = outter[key]
+ let outerValue = outer[key]
if (typeof innerValue === 'string') {
- if (innerValue !== outterValue) return false
+ if (innerValue !== outerValue) return false
} else {
if (
- !Array.isArray(outterValue) ||
- outterValue.length !== innerValue.length ||
- innerValue.some((value, i) => value !== outterValue[i])
+ !Array.isArray(outerValue) ||
+ outerValue.length !== innerValue.length ||
+ innerValue.some((value, i) => value !== outerValue[i])
)
return false
}
history.go(distance)
}
const routerHistory: RouterHistory = {
- // it's overriden right after
+ // it's overridden right after
// @ts-ignore
location: historyNavigation.location.value,
base,
if (!options.strict) pattern += '/?'
if (options.end) pattern += '$'
- // allow paths like /dynamic to only match dynamic or dynamic/... but not dynamic_somethingelse
+ // allow paths like /dynamic to only match dynamic or dynamic/... but not dynamic_something_else
else if (options.strict) pattern += '(?:/|$)'
const re = new RegExp(pattern, options.sensitive ? '' : 'i')
let started = false
// TODO: can we use something that isn't a mixin?
// TODO: this initial navigation is only necessary on client, on server it doesn't make sense
- // because it will create an extra unecessary navigation and could lead to problems
+ // because it will create an extra unnecessary navigation and could lead to problems
if (isClient)
app.mixin({
beforeCreate() {
* that is rendering this component.
* @param to - RouteLocationRaw we are navigating to
* @param from - RouteLocationRaw we are navigating from
- * @param next - function to validate, cancel or modify (by redirectering) the navigation
+ * @param next - function to validate, cancel or modify (by redirecting) the navigation
*/
beforeRouteLeave?: NavigationGuard
/**
* the query or the hash.
* @param to - RouteLocationRaw we are navigating to
* @param from - RouteLocationRaw we are navigating from
- * @param next - function to validate, cancel or modify (by redirectering) the navigation
+ * @param next - function to validate, cancel or modify (by redirecting) the navigation
*/
beforeRouteUpdate?: NavigationGuard
}
// TODO: beforeEnter has no effect with redirect, move and test
beforeEnter?: NavigationGuard<undefined> | NavigationGuard<undefined>[]
/**
- * Arbitraty data attached to the record.
+ * Arbitrary data attached to the record.
*/
meta?: Record<string | number | symbol, any>
// TODO: only allow a subset?
record.components[name] = resolvedComponent
const guard = resolvedComponent[guardType]
return (
- // @ts-ignore: the guard matcheds the instance type
+ // @ts-ignore: the guards matched the instance type
guard && guardToPromiseFn(guard, to, from, record.instances[name])()
)
})
} else {
const guard = rawComponent[guardType]
guard &&
- // @ts-ignore: the guard matcheds the instance type
+ // @ts-ignore: the guards matched the instance type
guards.push(guardToPromiseFn(guard, to, from, record.instances[name]))
}
}
*/
export type LocationQueryValue = string | null
/**
- * Possible values when definining a query
+ * Possible values when defining a query
*
* @internal
*/
* doesn't prepend a `?`
*
* @param query - query object to stringify
- * @returns string verion of the query without the leading `?`
+ * @returns string version of the query without the leading `?`
*/
export function stringifyQuery(query: LocationQueryRaw): string {
let search = ''