* 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.
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>