Re: [Django] #5090: Url patterns are case-sensitive.

80 views
Skip to first unread message

Django

unread,
Nov 29, 2013, 1:35:31 PM11/29/13
to django-...@googlegroups.com
#5090: Url patterns are case-sensitive.
-------------------------------------+-------------------------------------
Reporter: Alex Nickolaenkov | Owner:
<nickolaenkov@…> | mtredinnick
Type: Uncategorized | Status: closed
Component: HTTP handling | Version: master
Severity: Normal | Resolution: wontfix
Keywords: url handling | Triage Stage:
Has patch: 1 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by anonymous):

* ui_ux: => 0
* type: => Uncategorized
* severity: => Normal
* easy: => 0


Comment:

Replying to [comment:2 Alex Nickolaenkov <nickolaenkov@…>]:
> * Case-sensitive urls.
> Take a look:
> http://www.coastalbeat.com/news/2007/jul/30/simpsons/
> http://www.coastalbeat.com/news/2007/jul/30/Simpsons/
> [...]

Actually, your example is wrong, since the URL
http://www.gonaples.com/news/2007/Jul/30/simpsons/ will work correctly.
Suppose they are using Django, they would be using case insensitive
regexes ((?i) prefix, per [comment:5]), but their object lookup query is
not case-insensitive. They would have to use
`Article.objects.get(slug__iexact="Simpsons")` in addition to the case-
insensitive regex for the whole mechanism to work.

--
Ticket URL: <https://code.djangoproject.com/ticket/5090#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 12, 2022, 11:49:04 AM8/12/22
to django-...@googlegroups.com
#5090: Url patterns are case-sensitive.
-------------------------------------+-------------------------------------
Reporter: Alex Nickolaenkov | Owner: Malcolm
<nickolaenkov@…> | Tredinnick
Type: Uncategorized | Status: closed
Component: HTTP handling | Version: dev

Severity: Normal | Resolution: wontfix
Keywords: url handling | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by MiloLug):

What if just add, say `ipath` and `re_ipath`.
I even have an example of such code in my project:


{{{
import re
from functools import partial

from django.urls.resolvers import RoutePattern, RegexPattern,
_route_to_regex
from django.urls.conf import _path
from django.core.exceptions import ImproperlyConfigured


class IRoutePattern(RoutePattern):
def _compile(self, route):
return re.compile(_route_to_regex(route, self._is_endpoint)[0],
re.IGNORECASE)


class IRegexPattern(RegexPattern):
def _compile(self, regex):
"""Compile and return the given regular expression."""
try:
return re.compile(regex, re.IGNORECASE)
except re.error as e:
raise ImproperlyConfigured(
'"%s" is not a valid regular expression: %s' % (regex, e)
) from e


ipath = partial(_path, Pattern=IRoutePattern)
re_ipath = partial(_path, Pattern=IRegexPattern)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/5090#comment:7>

Reply all
Reply to author
Forward
0 new messages