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

[added] Greedy splat (**) #2401

Merged
merged 1 commit into from
Oct 28, 2015
Merged

[added] Greedy splat (**) #2401

merged 1 commit into from
Oct 28, 2015

Conversation

klzns
Copy link
Contributor

@klzns klzns commented Oct 28, 2015

As discussed #2284, this pull request add support to greedy splat **.

Example of matching:

/*/c matches /you/are/okay/c
/*/c does not match /you/are/cool/c
/**/c matches /you/are/cool/c

Fix #2284

@klzns klzns changed the title [added] Add greedy splat (**) [added] Greedy splat (**) Oct 28, 2015
@knowbody
Copy link
Contributor

thank you! great work 😄

knowbody added a commit that referenced this pull request Oct 28, 2015
[added] Greedy splat (**)
@knowbody knowbody merged commit 366ecf4 into remix-run:master Oct 28, 2015
@klzns
Copy link
Contributor Author

klzns commented Oct 28, 2015

@knowbody thanks! I'm glad that I contributed to react-router 😄

@leandrooriente
Copy link

Nice job 😄

@taion
Copy link
Contributor

taion commented Oct 30, 2015

Looking at this a little, do you think it'd be worth adding a caveat saying that e.g.

<Route path="**">
  <IndexRoute />
  <Route path="foo" />
  <Route path="bar" />
</Route>

will only ever match the index route? It should be obvious, but you never know.

@knowbody
Copy link
Contributor

I think it's a good idea @taion

@mjackson
Copy link
Member

There's already an open issue to add a warning about unreachable routes. We
should definitely take care of that soon.
On Fri, Oct 30, 2015 at 7:45 AM Mateusz Zatorski [email protected]
wrote:

I think it's a good idea @taion https://github.com/taion


Reply to this email directly or view it on GitHub
#2401 (comment).

@taion
Copy link
Contributor

taion commented Oct 30, 2015

Actually, can you reach any routes under splats? It looks like even

<Route path="*">
  <IndexRoute />
  <Route path="foo" />
  <Route path="bar" />
</Route>

can't match the non-index routes because of https://github.com/rackt/react-router/blob/v1.0.0-rc3/modules/PatternUtils.js#L84-L87.

This splat stuff and the implicit coercion of repeated route params to arrays is pretty confusing IMO.

@knowbody
Copy link
Contributor

@mjackson but we should have something like a debug mode for that, we don't want to check for the unreachable routes every time. Have a look at the initial work in #2351

@taion
Copy link
Contributor

taion commented Oct 30, 2015

Let's continue discussion in #2422. In working through #2421, I see a few edge cases that could lead to potentially surprising behavior, and I think this is an API that we should try to simplify.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 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

Successfully merging this pull request may close these issues.

5 participants