marrow / WebCore

WebCore, the super tiny and blazingly fast modular Python web nanoframework.
MIT License
96 stars 9 forks source link

Dispatcher incorrectly handles trailing slashes #195

Closed jmpurtle closed 4 years ago

jmpurtle commented 4 years ago

In development of a MCVE, I discovered that when one attempts to use the built in Object Dispatching mechanism on an url such as '/movies/', Webcore delivers a 404 response and navigating to '/movies' correctly renders as a call.

127.0.0.1 - - [11/May/2020 16:26:23] "GET / HTTP/1.1" 200 13
127.0.0.1 - - [11/May/2020 16:26:29] "GET /movies HTTP/1.1" 200 25
web.app.wcmdb.movie.controller:MoviesController.__call__() takes 1 positional argument but 2 were given
127.0.0.1 - - [11/May/2020 16:26:33] "GET /movies/ HTTP/1.1" 404 0

After some discussion, it appears that the splitting of the provided path occurs twice and the second instance does not handle a case where the split will return a single-element empty string on an empty string split and subsequently passed to RemainderArgsExtension.