Skip to content

Router with regular expression #12442

@felipedrumond

Description

@felipedrumond

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[x] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

I understand that is highly recommended to not use this tool when looking for support, but after spending hours of search and attempts to solve this issue, I don't have any other option but ask the community here.
In angular 2 beta.9-12 there was a way to use a regular expression to determine if some component should be used:

{   regex: '[a-z]+.[0-9]+',
    serializer: (params) => `{params.a}.params.b}`,
    component: MyComponent }  

This option is not available anymore ("@angular/router": "3.1.0"), so I'm struggling to redirect some urls do the right component. For instance, I can't distinguish between the two routes:

{ path: ':categoryUrl/:productUrl' } -> goes do product.component
{ path: ':categoryUrl/:page' } -> goes to category.component

Expected behavior

Router should provide a way to let us specify regular expressions to define if some route should be activated or not.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Keep organization of urls, specially keep existing SEO ranking.

Please tell us about your environment:

  • Angular version: 2.0.X

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

  • Node (for AoT issues): node --version =

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions