UrlMatcher
A function for matching a route against URLs. Implement a custom URL matcher
for Route.matcher
when a combination of path
and pathMatch
is not expressive enough.
type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult;
Usage notes
The following matcher matches HTML files.
export function htmlFiles(url: UrlSegment[]) {
return url.length === 1 && url[0].path.endsWith('.html') ? ({consumed: url}) : null;
}
export const routes = [{ matcher: htmlFiles, component: AnyComponent }];