Code

Ticket #5859: contrib_redirect_middleware.diff

File contrib_redirect_middleware.diff, 1006 bytes (added by E Miller <thnntn+djtrac@…>, 6 years ago)

redirect middleware w/iexact

Line 
1Index: middleware.py
2===================================================================
3--- middleware.py       (revision 6626)
4+++ middleware.py       (working copy)
5@@ -8,14 +8,14 @@
6             return response # No need to check for a redirect for non-404 responses.
7         path = request.get_full_path()
8         try:
9-            r = Redirect.objects.get(site__id__exact=settings.SITE_ID, old_path=path)
10+            r = Redirect.objects.get(site__id__exact=settings.SITE_ID, old_path__iexact=path)
11         except Redirect.DoesNotExist:
12             r = None
13         if r is None and settings.APPEND_SLASH:
14             # Try removing the trailing slash.
15             try:
16                 r = Redirect.objects.get(site__id__exact=settings.SITE_ID,
17-                    old_path=path[:path.rfind('/')]+path[path.rfind('/')+1:])
18+                    old_path__iexact=path[:path.rfind('/')]+path[path.rfind('/')+1:])
19             except Redirect.DoesNotExist:
20                 pass
21         if r is not None: