Fix path normalization of index route#347
Merged
Nehliin merged 1 commit intotower-rs:masterfrom Apr 11, 2023
Merged
Conversation
87b44d8 to
4b7fa0e
Compare
Contributor
Author
|
I just added an improved implementation which also removes multiple trailing slashes in the case of an index (e.g. |
Nehliin
reviewed
Mar 27, 2023
Collaborator
Nehliin
left a comment
There was a problem hiding this comment.
I don't mind the solution of adding a "/" but it feels wrong to do this within a function called remove_trailing_slash. Could this logic be extracted to before calling into the method? If not we should at least rename the function
Contributor
Author
|
How about |
Previously, `normalize_path` on `/` would result in an empty string, causing routers to return 404 on the index route. Fix this by defaulting to `/` if the resultant path would be empty. Fixes tower-rs#318.
4b7fa0e to
13dc41c
Compare
Collaborator
|
Merging this now since it's such a small change overall |
gezihuzi
pushed a commit
to gezihuzi/tower-http
that referenced
this pull request
Jul 19, 2023
Previously, `normalize_path` on `/` would result in an empty string, causing routers to return 404 on the index route. Fix this by defaulting to `/` if the resultant path would be empty. Fixes tower-rs#318.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously,
normalize_pathon/would result in an empty string, causing routers to return 404 on the index route. Fix this by defaulting to/if the resultant path would be empty.Fixes #318.