Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to match arbirarily deep routes? #2129

Closed
d4goxn opened this issue Sep 29, 2015 · 1 comment
Closed

Is it possible to match arbirarily deep routes? #2129

d4goxn opened this issue Sep 29, 2015 · 1 comment

Comments

@d4goxn
Copy link

d4goxn commented Sep 29, 2015

In my app, I have a category page that handles routes like

/entertainment/tv/simpsons
/food/recipes
/cars

I would like to match all of these with a single route handler, after matching higher precedence routes like /login and /edit. Something like:

<Route handler={App}>
  <Route path="/about-us" handler={Page}/>
  <Route path="/edit" handler={ArticleEditor}/>
  <Route path="/**" handler={CategoryIndex}/>
  <Route path="/:articleSlug" handler={Article}/>
</Route>

It seems that a * pattern only matches inside of slashes, it cannot actually match slashes. This is consistent with filesystem globs, so it is not really surprising. I do not want to abuse the NotFound route handler to match stuff, partly because that's just wrong, but also because it would prevent me from havingan even lower precedence route that matches articles: /:article-slug.

As far as I can tell, this would require a new feature - something like the ** shell glob operator that matches deep paths. Is this necessary? If so, is it desirable, and are there any special cases that I should be aware of while working on a PR? It looks like there are some special rules around the . character, after reading through #142.

@mjackson
Copy link
Member

mjackson commented Oct 6, 2015

You're using an old version of the router. In 1.0 (currently rc1) you can use * to match "all characters (non-greedy) up to the next character in the pattern, or to the end of the URL if there is none". There's no way to do this elegantly in the 0.13 API.

@mjackson mjackson closed this as completed Oct 6, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants