Route tolerance for trailing slash
See original GitHub issueENVIRONMENT
$ yarn rw --version
0.0.1-alpha.31
PROBLEM
I’d like both /url
and /url/
to match a single route.
Currently, if I use <Route path="/posts" ...>
that will match URL /posts
but not /posts/
. If I change the route to <Route path="/posts/" ...>
, it matches /posts/
but not /posts
.
When using React-Router, this is easy to solve using a combination of the strict
and exact
parameters, something like <Route strict={false} exact={true} path="/posts/" ...>
.
Is there an option to the Redwood Route object that controls tolerance for trailing slashes?
A regex for path-matching could also be a good approach.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Laravel - append a trailing slash in routes - Stack Overflow
Humm I think it looks possible through middleware eg. $ php artisan make:middleware slashesMiddleware.
Read more >HTTP 301 Permanent Redirect Filter For URLs Without ...
By default, Spring MVC is tolerant and accepts requests to URL mappings with request URLs both ending with and without a trailing slash...
Read more >failure to mount if a mount point ends with a slash in /etc/fstab
Here's why it fails to mount it: When systemd parses /etc/fstab, it trims the trailing slashes. When it comes to the mounting, ...
Read more >hapi — Ignore Trailing Slashes on Route Paths - Future Studio
The problem of trailing slashes on route paths can be kind of annoying and different platforms generate both URL styles: with and without ......
Read more >iRule to Add Trailing Slash Except for Extensions - DevCentral
iRule to Add Trailing Slash Except for Extensions ... { # Append slash and keep querystring when it exists HTTP::uri [HTTP::path]/[expr { "[URI::query ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@chris-hailstorm It’s an artifact of the implementation that regex syntax currently works in routes. I expect that will go away so that we can do an optimized parser-based route matcher in the future, but I need to think about it more.
Regarding trailing slashes, we could add a
trailingSlashes
option onRouter
that could be one of:Probably we would default to
never
. Would this solve your use case, or did you have some other requirement in mind?Hello! I just ran up against this in one of my Redwood Projects. Just wanted to drop a note here to mention that I’d find this feature helpful, and I appreciate all that you all are doing to make Redwood awesome 😄