-
-
Notifications
You must be signed in to change notification settings - Fork 711
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
Better handling for trailing slashes. (#2154) #2172
Conversation
This adds a trailing_slash option to <Router> and <Route>. By default, this option is backward compatible with current Leptos behavior, but users can opt into two new modes for handling trailing slashes.
Things still WIP:
|
Link to #2154 (the related feature request), please, GitHub! 😊 |
Quick question - is this the same as #2163? |
@rakshith-ravi #2163 isn't by me, it's by @skirsdeda. But we were discussing it as an incremental approach to this larger feature implementation in the feature request, so I provided some feedback over there and based these changes atop that work. IMO we probably shouldn't merge #2163 in its current state. Without 10915f9 the front- and back-end routing are slightly different. |
Yeah I got confused with the issue numbers for a second there. Like I said, super sleep deprived rn 😅
Ahh, got it. Greg will have a better idea about this, but just my two cents - how about y'all put a PR on each other's branches and then have the complete slash handling as a single PR to main? That way, it'll be a feature complete PR. On the flip side, it would mean a larger PR, so reviewing it might be difficult. Idk. Just putting both sides of the argument |
This is the full PR. Minus a couple TODOs and any suggestions I get from maintainers. 😊 |
This looks pretty solid to me, I've started the checks. I think we should add some mention to the interplay between the Axum and Actix routers, and the Leptos one. Does Axum behave the same way? |
Probably also want to run cargo clippy against your repo |
|
Are all of these test failures in CI valid failures that I need to look into? Or are some just known to be flakey? |
@gbj is probably more familiar than I, but some of the examples test suites are failing now. Is this common? |
I'll have the CI rerun the failed tasks just in case. I would need to check out the branch and test out the examples myself to give a definitive answer, but I'm seeing failing e2e tests on several examples that do involve routing, so it's worth checking whether those examples actually work with the changes. |
OK, thanks. I hope to have more time to look into these tonight. Hopefully it's just the known issue with maybe TMI but just to share: I've already looked into that a bit and found it was because of the changes to path normalization. The problem is that path normalization works the same everywhere … except root paths. For both Actix and Axum, (and HTTP/HTML, AFAICT) root paths of "/" and "" are equivalent. So the error comes when Leptos specifies a root path of "", but the web server gives us a path of "/", which Leptos doesn't find a match for (in this branch, given its more precise path matching.) I've got a couple different fixes I'm testing out. |
This path is the exception to the rule and *should* be treated as equivalent regardless of its trailing slash.
OK, I've done local testing with Actix and Axum and have fixed my blocking issue. I bet that was the breaking issue for those integration tests, given they couldn't even render the first page of the site.🤞 I started down the path of trying to run the tests for myself locally but it looks like they require manual installation of some test tools and it's getting late here. If one of y'all can kick these off tonight/tomorrow I'll come back and check results here. Thank you! 😊 |
Looks promising, although it seems to have failed a cargo fmt check |
Weird, I would've sworn I ran Thankfully that's an easy one to fix! I assume/hope we'll squash merge this messy history away? 😅 |
And merged? Just like that! Thank you so much! I'll definitely be using this in my own project(s)! 😊 |
Yep, the tests passed, it’s a useful feature, and the code’s solid. Thanks for contributing!
…On Thu, Jan 11, 2024, at 2:24 PM, Cody Casterline wrote:
And merged? Just like that! Thank you so much! I'll definitely be using this in my own project(s)! 😊
—
Reply to this email directly, view it on GitHub <#2172 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABVBTCO5DYIXCYKNOBODGJLYOBRCHAVCNFSM6AAAAABBQXEW3SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBYGA3DKOJTGQ>.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
@NfNitLoop @benwis Sorry to say this PR broke the router in a way that unfortunately was not caught by the existing CI setup. Two examples:
Given the breakages in existing code I'm going to have to revert this and yank the last two releases, since I unfortunately didn't catch it before then. If you can find a way to implement this that does not cause these issues, I will be happy to review a new PR. |
* retain trailing slashes in paths but leave matching trail-slash-insensitive * fix: Allow trailing slashes to remain in leptos_path. * Better handling for trailing slashes. (leptos-rs#2154) This adds a trailing_slash option to <Router> and <Route>. By default, this option is backward compatible with current Leptos behavior, but users can opt into two new modes for handling trailing slashes. * cargo fmt * Fix redirect routes for wildcard patterns. * Clippy fixies * (Re)Reduce the scope of PossibleBranchContext's internals. * Test real code, not copied code. * Test TrailingSlash redirects. * Fixes and more tests for matching "" && "/". This path is the exception to the rule and *should* be treated as equivalent regardless of its trailing slash. * cargo fmt --------- Co-authored-by: Tadas Dailyda <[email protected]>
* retain trailing slashes in paths but leave matching trail-slash-insensitive * fix: Allow trailing slashes to remain in leptos_path. * Better handling for trailing slashes. (leptos-rs#2154) This adds a trailing_slash option to <Router> and <Route>. By default, this option is backward compatible with current Leptos behavior, but users can opt into two new modes for handling trailing slashes. * cargo fmt * Fix redirect routes for wildcard patterns. * Clippy fixies * (Re)Reduce the scope of PossibleBranchContext's internals. * Test real code, not copied code. * Test TrailingSlash redirects. * Fixes and more tests for matching "" && "/". This path is the exception to the rule and *should* be treated as equivalent regardless of its trailing slash. * cargo fmt --------- Co-authored-by: Tadas Dailyda <[email protected]>
* retain trailing slashes in paths but leave matching trail-slash-insensitive * fix: Allow trailing slashes to remain in leptos_path. * Better handling for trailing slashes. (leptos-rs#2154) This adds a trailing_slash option to <Router> and <Route>. By default, this option is backward compatible with current Leptos behavior, but users can opt into two new modes for handling trailing slashes. * cargo fmt * Fix redirect routes for wildcard patterns. * Clippy fixies * (Re)Reduce the scope of PossibleBranchContext's internals. * Test real code, not copied code. * Test TrailingSlash redirects. * Fixes and more tests for matching "" && "/". This path is the exception to the rule and *should* be treated as equivalent regardless of its trailing slash. * cargo fmt --------- Co-authored-by: Tadas Dailyda <[email protected]>
This adds a trailing_slash option to
<Router>
and<Route>
.By default, this option is backward compatible with current Leptos
behavior, but users can opt into two new modes for handling trailing
slashes.