[Router] Add defaultUrlMatcher to public API
See original GitHub issueπ feature request
Relevant Package
This feature request is for @angular/router
Description
There should be ability to access defaultUrlMatcher from userβs code. Ability to access and use it in custom implementations of UrlMatcher will ease developing of custom url matchers like in this question: https://stackoverflow.com/a/41543827/5358442
function digitsMatcher(segments: UrlSegment[], segmentGroup: UrlSegmentGroup, route: Route): UrlMatchResult | null {
const result = defaultUrlMatcher(segments, segmentGroup, route);
if (!result || !result.consumed || result.consumed.length < 1) {
return;
}
const re = /^\d+$/;
const match = re.exec(result.consumed[0].path);
if (match) {
return result;
}
return null;
}
Describe the solution youβd like
There should be ability to import default URL matcher and call it from user-defined custom matcher.
Describe alternatives youβve considered
Another solution of βmyβ case can be adding support of constraints for route params with few built-in constraints like Integer and Regex and ability to create custom constraints. This could look something like this:
const routes: Routes = [
{ path: ':clientId/:lang', component: ClientOpenComponent,
constraints: {
clientId: [RouteParamConstraints.Integer], /*built-in*/
lang: [LangRouterParamConstraint] } /*custom*/
}];
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:5 (2 by maintainers)
Top Results From Across the Web
defaultUrlMatcher - Angular
Matches the route configuration ( route ) against the actual URL ( segments ). See more... defaultUrlMatcher(segments: UrlSegment[], segmentGroup:Β ...
Read more >Routers - Django REST framework
REST framework adds support for automatic URL routing to Django, and provides you with a simple, quick and consistent way of wiring your...
Read more >How to match route only if param is integer in Angular2?
You can pass a custom matcher to your route import { defaultUrlMatcher } from '@angular/router/src/shared'; function digitsMatcher(segments: UrlSegment[],Β ...
Read more >Working with routes for HTTP APIs - Amazon API Gateway
A greedy path variable catches all child resources of a route. To create a greedy path variable, add + to the variable nameβfor...
Read more >Creating a REST API with Node.js - YouTube
Our RESTful API needs more Routes! Learn how to add more routes to our Node + Express project!Join the full Node.js course:Β ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angularβs feature request process in our documentation.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.