/**
* Transforms an URI into a normalized history location
* @param parseQuery
- * @param location URI to normalize
+ * @param location - URI to normalize
* @returns a normalized history location
*/
export function parseURL(
/**
* Strips off the base from the beginning of a location.pathname
- * @param pathname location.pathname
- * @param base base to strip off
+ * @param pathname - location.pathname
+ * @param base - base to strip off
*/
export function stripBase(pathname: string, base: string): string {
if (!base || pathname.indexOf(base) !== 0) return pathname
import { inject } from 'vue'
import { routerKey, routeLocationKey } from './utils/injectionSymbols'
+export { RouterHistory } from './history/common'
+
export {
RouteLocationNormalized,
RouteLocationOptions,
/**
* Resolves a location. Gives access to the route record that corresponds to the actual path as well as filling the corresponding params objects
- * @param location MatcherLocation to resolve to a url
- * @param currentLocation MatcherLocationNormalized of the current location
+ * @param location - MatcherLocation to resolve to a url
+ * @param currentLocation - MatcherLocationNormalized of the current location
*/
function resolve(
location: Readonly<MatcherLocation>,
* Parses a url and returns the matched params or nul if it doesn't match. An
* optional param that isn't preset will be an empty string. A repeatable
* param will be an array if there is at least one value.
- * @param path url to parse
+ * @param path - url to parse
* @returns a Params object, empty if there are no params. `null` if there is
* no match
*/
parse(path: string): PathParams | null
/**
* Creates a string version of the url
- * @param params object of params
+ * @param params - object of params
* @returns a url
*/
stringify(params: PathParams): string
/**
* Creates a path parser from an array of Segments (a segment is an array of Tokens)
*
- * @param segments array of segments returned by tokenizePath
- * @param extraOptions optional options for the regexp
+ * @param segments - array of segments returned by tokenizePath
+ * @param extraOptions - optional options for the regexp
* @returns a PathParser
*/
export function tokensToParser(
/**
* Compares an array of numbers as used in PathParser.score and returns a
* number. This function can be used to `sort` an array
- * @param a first array of numbers
- * @param b second array of numbers
+ * @param a - first array of numbers
+ * @param b - second array of numbers
* @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
* should be sorted first
*/
/**
* Compare function that can be used with `sort` to sort an array of PathParser
- * @param a first PathParser
- * @param b second PathParser
+ * @param a - first PathParser
+ * @param b - second PathParser
* @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
*/
export function comparePathParserScore(a: PathParser, b: PathParser): number {
/**
* Trigger errorHandlers added via onError and throws the error as well
- * @param error error to throw
- * @param shouldThrow defaults to true. Pass false to not throw the error
+ * @param error - error to throw
+ * @param shouldThrow - defaults to true. Pass false to not throw the error
*/
function triggerError(error: any, shouldThrow: boolean = true): void {
markAsReady(error)
/**
* Mark the router as ready, resolving the promised returned by isReady(). Can
* only be called once, otherwise does nothing.
- * @param err optional error
+ * @param err - optional error
*/
function markAsReady(err?: any): void {
if (ready) return
/**
* Guard called when the router is navigating away from the current route
* that is rendering this component.
- * @param to RouteLocation we are navigating to
- * @param from RouteLocation we are navigating from
- * @param next function to validate, cancel or modify (by redirectering) the navigation
+ * @param to - RouteLocation we are navigating to
+ * @param from - RouteLocation we are navigating from
+ * @param next - function to validate, cancel or modify (by redirectering) the navigation
*/
beforeRouteLeave?: NavigationGuard
/**
* Guard called whenever the route that renders this component has changed but
* it is reused for the new route. This allows you to guard for changes in params,
* the query or the hash.
- * @param to RouteLocation we are navigating to
- * @param from RouteLocation we are navigating from
- * @param next function to validate, cancel or modify (by redirectering) the navigation
+ * @param to - RouteLocation we are navigating to
+ * @param from - RouteLocation we are navigating from
+ * @param next - function to validate, cancel or modify (by redirectering) the navigation
*/
beforeRouteUpdate?: NavigationGuard
}
/**
* Transform a queryString into a query object. Accept both, a version with the leading `?` and without
* Should work as URLSearchParams
- * @param search
+ * @param search - search string to parse
* @returns a query object
*/
export function parseQuery(search: string): LocationQuery {
/**
* Stringify an object query. Works like URLSearchParams. Doesn't prepend a `?`
- * @param query
+ * @param query - query object to stringify
*/
export function stringifyQuery(query: LocationQueryRaw): string {
let search = ''
* Transforms a RawQuery intoe a NormalizedQuery by casting numbers into
* strings, removing keys with an undefined value and replacing undefined with
* null in arrays
- * @param query
+ * @param query - query object to normalize
*/
export function normalizeQuery(
query: LocationQueryRaw | undefined