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.

wild card route weird behavior

See original GitHub issue

I’m submitting a …

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

Routes definition:

const routes = {
  path: '',
  children: [
// paths
  {
     path: '(.*)'
    action(context, params) {
      console.log(params);
    }
  ]
}

Going to the route / -which I don’t have a defined route for - will log this to the console {0: '/'} The problem is that defining the path as (.*) will create an unnamed parameter with the value ‘/’, and defining the path like this /(.*) will create an unnamed parameter with value ‘’ (empty string). I use a generic action because I handle all my routes in the same way, so suddenly I find the url of my app looks like this ‘/?0=%2F’ or like this ‘?0=’ or worse - if I go to ‘blah’ the url will look like this ‘/?=%2Fblah’

I’ve read the path-to-regex documentation, and I found out that this is the desired behavior for the unnamed parameters (.*), but this is not the desired behavior for wild card path. Please provide another way to handle wild card paths, while keeping the same behavior for unnamed parameters, as they are not the same case.

Side note: I love your work, I have been searching for a universal router for about a year before I have found your package, and I have not used any other router since. Brilliant work, great flexibility. I will submit a PR soon to add more recipes.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
frenzzycommented, Mar 4, 2018

Have you tried to use regexp path: /.*/,? https://jsfiddle.net/b0w9mjck/118/

0reactions
AhmadMayocommented, Mar 4, 2018

This should be mentioned in the read me

Read more comments on GitHub >

github_iconTop Results From Across the Web

linux - `locate` wildcard strange behavior - why? - Super User
It seems that the pattern is not enclosed in stars, if there is already one wildcard in the pattern. Disclaimer: I did some...
Read more >
Odd results mixing fully-tokenized attribute-route and wildcard ...
The presence of the attribute-route seems to clobber requests that should go through the separate wildcard-mapped middleware.
Read more >
Angular router '**' wildcard as a catch-all with child routes ...
This was a bug with the router solved on issue #18139, I updated to 5.2.1 on my package.json to get the fix "@angular/core":...
Read more >
Think You Understand Wildcards? Think Again. - Medium
Strictly speaking, he was right, but the name is a good analogy because in some card games the Joker or “wild card” can...
Read more >
React Navigation - Ionic Framework
The React Navigation guide covers routing in an app built with Ionic and React. Learn to define a redirect path for router links...
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