Carl Meyer avatar Carl Meyer committed 48e3391

Fix non-lowercase url paths broken in case-insensitive-locale commit; thanks Alex Marandon for the report.

Comments (0)

Files changed (2)

localeurl/middleware.py

             if accept_langs:
                 locale = accept_langs[0]
         locale_path = utils.locale_path(path, locale)
-        if locale_path != request.path_info.lower():
+        # locale case might be different in the two paths, that doesn't require
+        # a redirect (besides locale they'll be identical anyway)
+        if locale_path.lower() != request.path_info.lower():
             locale_url = utils.add_script_prefix(locale_path)
 
             qs = request.META.get("QUERY_STRING", "")

localeurl/tests/tests.py

         self.assertEqual('/test/bla/bla/', r1.path_info)
 
 
+    def test_non_lowercase_path(self):
+        r1 = self.request_factory.get('/nl-nl/TEST/bla/bla/')
+        r2 = self.middleware.process_request(r1)
+        self.assertEqual(None, r2)
+        self.assertEqual('nl-nl', r1.LANGUAGE_CODE)
+        self.assertEqual('/TEST/bla/bla/', r1.path_info)
+
+
     def test_locale_independent_url(self):
         r1 = self.request_factory.get('/test/independent/bla/bla/')
         r2 = self.middleware.process_request(r1)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.