Skip to content

[Router] Add defaultUrlMatcher to public API #35928

Closed

Description

@RoboBurned

🚀 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*/
}];

Activity

  1. added this to the needsTriage milestone on Mar 7, 2020
  2. added
    featureLabel used to distinguish feature request from other issues
    on Mar 10, 2020
  3. modified the milestones: needsTriage, Backlog on Mar 10, 2020
  4. amakhrov commented on Nov 23, 2020

    @amakhrov

    Public defaultUrlMatcher would make it quite simple to write a custom matcher that emulates a missing "multiple paths for the same route" capability.

  5. CarlosHAraujo commented on Feb 9, 2021

    @CarlosHAraujo

    +1

  6. angular-robot commented on Jun 4, 2021

    @angular-robot
    Contributor

    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.

  7. angular-robot commented on Jun 25, 2021

    @angular-robot
    Contributor

    Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

    We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

    You can find more details about the feature request process in our documentation.

  8. angular-automatic-lock-bot commented on Sep 1, 2022

    @angular-automatic-lock-bot

    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.

  9. locked and limited conversation to collaborators on Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: routerfeatureLabel used to distinguish feature request from other issuesfreq1: low

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions