Commits

Simon Luijk committed e5049cf

Don't try and parse referrer if there isn't one

Signed-off-by: Simon Luijk <simon@simonluijk.com>

  • Participants
  • Parent commits 48e3391

Comments (0)

Files changed (2)

File localeurl/tests/tests.py

         reload(localeurl_settings)
         self.client.post('/change/', data={'locale': 'de', 'next': '/foo'})
         self.assertNotEqual("de", self.client.session.get('django_language'))
+
+    def test_change_without_next(self):
+        response = self.client.post('/change/', data={'locale': 'de'})
+        self.assertEqual(response.status_code, 302)

File localeurl/views.py

     """
     next = request.REQUEST.get('next', None)
     if not next:
-        next = urlsplit(request.META.get('HTTP_REFERER', None))[2]
+        referrer = request.META.get('HTTP_REFERER', None)
+        if referrer:
+            next = urlsplit(referrer)[2]
     if not next:
         next = '/'
     _, path = utils.strip_path(next)