Closed einar-hjortdal closed 5 months ago
The router specifically adds slashes at the end to bring all URLs to a single standard. Because in certain situations it becomes difficult to match many variations of url spelling. For now it just works that way. There are no workarounds.
P.S. is this router based on another router project? I am curious
No. it's fully new project, but inspired angular router API
I stand by these proposed changes:
RouterLink
navigate to routes without trailing slashes by default: <RouterLink to='/foo'>
navigates to /foo
/foo/
becomes /foo
/foo/
match the path /foo
too: path: '/foo/'
matches /foo
Point 1 and 2 is the behavior I consider normal and is reflected by the behavior of the majority of the web. Point 3 I think would offer more consistency.
I am confused by how route paths work. I define routes without trailing slashes
When I navigate to
/contact
the path matches the route and it renders theContact
component. When I navigate to/contact/
is also matches. On/contact
,useMatch().path
returns/contact/
.<RouterLink to='/contact'>Contact</RouterLink>
bring me to/contact/
.This made me think that routes should always have trailing slashes, but this was a mistake.
When I navigate to
/contact
the path does not match.Is there a way to:
/contact
/contact
from/contact/
/contact/
match the path/contact
tooTrailing slashes are unusual to see. Right now I can see
https://github.com/atellmer/dark/issues/new
in this tab, nothttps://github.com/atellmer/dark/issues/new/
P.S. is this router based on another router project? I am curious