Skip to content

support ** wildcard between path segments (e.g., /foo/**/bar) #60821

@alan-agius4

Description

@alan-agius4

Which @angular/* package(s) are relevant/related to the feature request?

No response

Description

Problem

Angular Router currently supports ** only as a catch-all at the end of a route. It lacks support for multi-segment wildcards between fixed segments—e.g., /foo/**/bar should match /foo/a/bar, /foo/a/b/c/bar, but not /foo/bar.

The only workaround today is a custom UrlMatcher, which introduces unnecessary complexity, boilerplate, and testing burden for a common pattern.

Proposal

Component Access

Intermediate segments could be exposed via ActivatedRoute, e.g.:

const segments = route.snapshot.paramMap.get('wildcardSegments');

Allow ** to be used between segments in the path property:

{ path: 'foo/**/bar', component: MyComponent }

Matching rules:

  • Must start with foo, end with bar
  • Must include one or more intermediate segments

Examples:

  • /foo/a/bar, /foo/a/b/c/bar
  • /foo/bar, /foo/a/b/baz

Benefits

  • Declarative, readable routing for hierarchical paths
  • Avoids verbose UrlMatcher implementations
  • Improves DX, reduces boilerplate, aids tooling and static analysis

Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions