Space before the type declartion in route throws a 404 #2720
Unanswered
parz3val
asked this question in
Potential Issue
Replies: 1 comment
-
We could also throw a syntax error like Django, which I am also open to. But django does things like this urlpatterns = [
path("articles/2003/", views.special_case_2003),
path("articles/<int:year>/", views.year_archive),
path("articles/<int:year>/<int:month>/", views.month_archive), And throws error if users try path("articles/<int: year>", views.smth), It'll throw an error saying there's a whitespace in the path. in _route_to_regex
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: URL route 'articles/<int: year>' cannot contain whitespace in angle brackets <…>. |
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
-
Adding a space before parameter type in the route will throw a 404, but will not give any runtime errors.
Reproduction:
I don't know if its intentional, but I somehow ended up thinking I could provide types in a same way as I do in python, and ended up shipping this bug in production.
I was thinking it would be nice to allow the space before the type declaration or throw an error when serving the app if user adds space in the route.
Here's what the current route declaration allows
Here's what I was thinking we could do
If its up for discussion, I would like to open a PR for this as we've already added this feature for our frozen fork of Starlette.
Beta Was this translation helpful? Give feedback.
All reactions