Skip to content

Matching both path and path/ #853

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

Closed
andrewdeandrade opened this issue Feb 19, 2015 · 4 comments
Closed

Matching both path and path/ #853

andrewdeandrade opened this issue Feb 19, 2015 · 4 comments

Comments

@andrewdeandrade
Copy link

The path matching document doesn't really indicate how to get an app to mount to both path and path/ (with the trailing slash).

I recently encountered this problem when mounting an application as an express sub-app (which will always mount the sub-app with a trailing slash).

@mrtnbroder
Copy link

Also got the same problem. My DefaultRoute has to work on the following paths:

/us, /us/ however, it only works on /us

<Route path='/us' handler={require('./views/Handler')}>
  <DefaultRoute name='frontpage' handler={require('./views/Frontpage/Frontpage')} />
  <NotFoundRoute name='NotFound' handler={require('./views/NotFound/NotFound')} />
</Route>

Is this the only solution for this?

<Redirect from="/us/" to="/us" />

@andrewdeandrade
Copy link
Author

I tried the redirect option, but then it doesn't work if the app is mounted somewhere that redirects to trailing slashes. What I want is it to respond to both.

@mrtnbroder
Copy link

I asked a similar question earlier, try this:

<Route path='/us/?' handler={require('./views/Handler')}>

notice the /? at the end.

@mjackson
Copy link
Member

We really need an easy way to make the trailing slash optional. Let's follow up in #820.

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