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 with regular expression

See original GitHub issue

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 =

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:10
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
rafaelss95commented, Dec 12, 2016

Is there any place that I can see how to use this new matcher? I read the part in API reference and the link for UrlMatcher seems broken.

7reactions
thefillcommented, May 7, 2017

Any chance to add gist by @matanshukry to the official documentation? As far as I can see a link to documentation for urlmatcher on the official documentation for router is still broken: broken url.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using regular expressions in express application with router ...
I am trying to use a regex pattern instead of a string in the app.use statement that sets up my Router middleware for...
Read more >
How to setup Regex for ExpressJS router url in Node.js
Setup Regex in URL:​​ We can easily set up Regex for our Express Router by following these two points: To make our route...
Read more >
Performant URL routing — with PHP and regular expressions ...
A url router evaluates the requested URL and interprets it according to defined ... Simple tutorial for a performant URL routing with PHP...
Read more >
06 - Use Regular Expressions with Routes - YouTube
Add routing to your React apps with React Router v5 (incl. hooks) ... create powerful rules to define the paths of your routes...
Read more >
Regular Expressions
A regular expression is a pattern to match against an input string. You specify the pattern that a string must match when you...
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