Inconsistend handling of tailing slashes with prefix mounts. #3086
Unanswered
defnull
asked this question in
Potential Issue
Replies: 1 comment
-
|
I noticed this issue because I want to have a 'catch all' route at the end of my routing table that handles all requests not handled by a mounted application. This 'catch all' route unfortunately breaks requests without a tailing slash. I had to add an explicit redirect for every single prefix mount. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Given the following example:
The tests pass. Both
GET /prefixandGET /prefix/are are handled by the firstMountand return a 200 response. This is expected, because the defaultRouterhasredirect_slashesenabled.When I now un-comment the second
Mount, it stops working. AGET /prefix/request still works as expected and is handled by the firstMount, butGET /prefixwill no longer match the firstMountand instead be handled by theStaticFilesapp.This is unexpected. Mounts with a prefix should always handle requests that match their prefix. If there is no remainder after the prefix was removed from the requested path, they should either trigger the
/sub-route, or allow sub-routes with an empty path. This logic should live inMountand not inRouterto avoid the inconsistent behavior ofRouter(redirect_slashes=True)described above. The logic inRouteris only triggered if there is no match at all for the no-slash path, which is not the case here.Beta Was this translation helpful? Give feedback.
All reactions