/** * Universal Router (https://www.kriasoft.com/universal-router/) * * Copyright (c) 2015-present Kriasoft. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ import type { Key } from 'path-to-regexp'; import { type Match } from './matchPath.js'; import type { IndexedParams, Route } from './types.t.js'; export type MatchWithRoute = Match & Readonly<{ route: Route; }>; /** * Traverses the routes tree and matches its nodes to the given pathname from * the root down to the leaves. Each match consumes a part of the pathname and * the matching process continues for as long as there is a matching child * route for the remaining part of the pathname. * * The returned value is a lazily evaluated iterator. * * The leading "/" in a route path matters only for the root of the routes * tree (or if all parent routes are ""). In all other cases a leading "/" in * a child route path has no significance. * * The trailing "/" in a _route path_ matters only for the leaves of the * routes tree. A leaf route with a trailing "/" matches only a pathname that * also has a trailing "/". * * The trailing "/" in a route path does not affect matching of child routes * in any way. * * The trailing "/" in a _pathname_ generally does not matter (except for * the case of leaf nodes described above). * * The "" and "/" routes have special treatment: * 1. as a single route * the "" and "/" routes match only the "" and "/" pathnames respectively * 2. as a parent in the routes tree * the "" route matches any pathname without consuming any part of it * the "/" route matches any absolute pathname consuming its leading "/" * 3. as a leaf in the routes tree * the "" and "/" routes match only if the entire pathname is consumed by * the parent routes chain. In this case "" and "/" are equivalent. * 4. several directly nested "" or "/" routes * - directly nested "" or "/" routes are 'squashed' (i.e. nesting two * "/" routes does not require a double "/" in the pathname to match) * - if there are only "" in the parent routes chain, no part of the * pathname is consumed, and the leading "/" in the child routes' paths * remains significant * * Side effect: * - the routes tree `{ path: '' }` matches only the '' pathname * - the routes tree `{ path: '', children: [ { path: '' } ] }` matches any * pathname (for the tree root) * * Prefix matching can be enabled also by `children: true`. */ declare function matchRoute(route: Route, pathname: string, ignoreLeadingSlash?: boolean, parentKeys?: readonly Key[], parentParams?: IndexedParams): Iterator, undefined, Route | undefined>; export default matchRoute; //# sourceMappingURL=matchRoute.d.ts.map