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
Link to "/" with basename adds extra trailing slash #6226
Comments
When using a basename, this is expected behavior for the root route. |
thanks @timdorr, I've implemented a server side redirect as a workaround, looks like I'll just stick with that! Do you have any explanation or link to a discussion thread for why this was decided to be the expected behavior? It doesn't seem ideal since the root route is a file rather than a directory. |
Is there any way to get the behavior that @mmartha is looking for using |
@timdorr Can you pls elaborate on why this is the case? Given:
I'm struggling to understand why 'foo/bar' (root route) adds a trailing slash yet 'foo/bar/baz' does not add one. Other than redirects, is there anyway to stop this happening? |
This use case should be achievable after the changes in #8861. The basename + link should now be able to control trailing slash behavior when routing to the root: This setup: <BrowserRouter basename="/app">
<Routes>
<Route path="" element={
<>
<Link to="" /> {/* No trailing slash */}
<Link to="/" /> {/* Trailing slash */}
</>
}
/>
</Routes>
</BrowserRouter> Should render: <a href="/app">
<a href="/app/"> The same goes with navigations upwards to the root - The new logic should be such that if either |
Version
4.2.0
Test Case
https://codesandbox.io/s/6llwm7m8zz
Steps to reproduce
Expected vs. Actual Behavior
the link takes me to
http://host/foo/bar/
(with trailing slash) when I expecthttp://host/foo/bar
(without trailing slash)The text was updated successfully, but these errors were encountered: