Repository navigation
Split path components that contain a slash when registering routes - #157
Open
dioKaratzas wants to merge 2 commits into
Open
dioKaratzas wants to merge 2 commits into
dioKaratzas wants to merge 2 commits into
Conversation
Summary: - Register a component like "users/:id" as the components it spells out, the same as ["users", ":id"] - Handle slashes in constants, parameters and partial parameters - Cover constants, parameters, catchalls and partials with a parameterized router test
Summary:
- Add a ":{name}.md/raw" case to the slash-splitting router test
Author
|
@0xTim @gwynne, one question on encoded slashes. Before this change Should |
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.
Fixes vapor/vapor#3349. Follow-up to #155: as discussed there, slashes are now parsed at routing build time instead of rejected.
app.get("te/st")used to register a singlete/stcomponent, so/te/streturned 404.TrieRouterBuilder.register(_:at:)now splits such components into the ones they spell out, so"users/:id"registers the same as["users", ":id"]. This covers constants, parameters (":id/edit") and partials (":{name}.md/raw"). Components without a slash are unchanged.Splitting happens once per route at registration; the lookup code is unchanged.
Covered by a parameterized test in
RouterTests. Also checked end to end in Vapor (app.get("te/st"),app.get("users/:id"),app.grouped("api/v1")).Encoded slashes, checked in Vapor against routing-kit 5.0.0-beta.3 and this branch:
/te%2Fst"te/st"/te/st"te/st"/files/a%2Fb"files", ":name"a/b)a/b)/docs/a%2Fb"docs/:name"a/b)