Feature: Retained Trailing Slash on URLs #228
dwighthouse
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the Discord, I had a long discussion with @Brendan-csel about trailing slashes. This topic was created at his suggestion.
In sort, I wish to have trailing slashes retained when navigating. Currently, solid-router correctly functions whether there is a trailing slash or not. Both
https://a.com/b
andhttps://a.com/b/
both result in the same page, as one would expect. However, due to the normalization that takes place when matching paths to definitions of paths in the router, currently all trailing slashes will be removed.That is, even if your definition and link are such:
The result in the address bar when navigating to this page will be
https://a.com/a
.For stylistic/consistency reasons, some would like to have those slashes retained. Not sure how many, but I'm one of them.
There are multiple options:
path
value in the definition for a route.I prefer option 3, as it would allow devs to specify intent without introducing a new setting. If their path says
/a
then they don't get a trailing slash. If it says/a/
, then they do get one.I believe this could be accomplished by intercepting the path updating functionality right before the address bar is updated, check the definition for that normalized path, and then add the trailing slash if appropriate as the History API is interacted with.
What do you think? Is this something that would be desired by others? Is this something that the maintainers would allow? I'm not opposed to working on it myself, but I want to make sure it would be accepted.
Beta Was this translation helpful? Give feedback.
All reactions