Router: How to handle trailing slashes

Created on 19 Jul 2018  路  4Comments  路  Source: reach/router

How would one handle forcing trailing slashes with the reach router? I tried using Redirect manually since I couldn't find any global props for it, but as the path ranking seems to ignore trailing slashes, this results in an infinite redirect loop:

<Router>
  <Redirect from="/path" to="/path/" />
  <Component path="/path/" />
</Router>
question

Most helpful comment

Is this still an issue? This is coming up on Google 2 years later and I have the exact same request

All 4 comments

+1
from my understanding, a trailing slash is helpful in describing a "folder", or a "base uri" in a server-side router, in accordance to rfc 3986, which describes a standard path resolution including relative paths (check section 5).
I believe it's also similar to how a unix path resolution works.

imo it might be worthwhile to use this as a convention.

I am also interested in this answer: some sort of a "strict" mode for matching trailing slashes? Another way to look at a trailing slash is as creating a zero-length path segment at the end - would be great to see a way to handle this more explicitly.

I wonder if there is a way to enforce a redirect to have consistent URLs from an SEO perspective. For example, a component

<Component path="app/someitem/:itemId" />

Becomes available at both /app/someitem/12345 and /app/someitem/12345/

Is this still an issue? This is coming up on Google 2 years later and I have the exact same request

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanflorence picture ryanflorence  路  4Comments

kbrgl picture kbrgl  路  4Comments

ssured picture ssured  路  3Comments

Kadrian picture Kadrian  路  5Comments

thupi picture thupi  路  4Comments