question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
angular-robot[bot]commented, Jun 4, 2021

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.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 1, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found