diff --git a/django/middleware/locale.py b/django/middleware/locale.py
index 628782b..f693e4d 100644
a
|
b
|
class LocaleMiddleware(object):
|
31 | 31 | and self.is_language_prefix_patterns_used()): |
32 | 32 | urlconf = getattr(request, 'urlconf', None) |
33 | 33 | language_path = '/%s%s' % (language, request.path_info) |
34 | | if settings.APPEND_SLASH and not language_path.endswith('/'): |
35 | | language_path = language_path + '/' |
| 34 | path_valid = is_valid_path(language_path, urlconf) |
| 35 | if (not path_valid and settings.APPEND_SLASH |
| 36 | and not language_path.endswith('/')): |
| 37 | path_valid = is_valid_path("%s/" % language_path, urlconf) |
36 | 38 | |
37 | | if is_valid_path(language_path, urlconf): |
| 39 | if path_valid: |
38 | 40 | language_url = "%s://%s/%s%s" % ( |
39 | 41 | request.is_secure() and 'https' or 'http', |
40 | 42 | request.get_host(), language, request.get_full_path()) |
diff --git a/tests/regressiontests/i18n/patterns/tests.py b/tests/regressiontests/i18n/patterns/tests.py
index 358cdf6..639e03f 100644
a
|
b
|
class URLTranslationTests(URLTestCaseBase):
|
115 | 115 | |
116 | 116 | with translation.override('nl'): |
117 | 117 | self.assertEqual(reverse('users'), '/nl/gebruikers/') |
| 118 | self.assertEqual(reverse('prefixed_xml'), '/nl/prefixed.xml') |
118 | 119 | |
119 | 120 | with translation.override('pt-br'): |
120 | 121 | self.assertEqual(reverse('users'), '/pt-br/usuarios/') |
… |
… |
class URLRedirectWithoutTrailingSlashTests(URLTestCaseBase):
|
186 | 187 | self.assertIn(('http://testserver/en/account/register/', 301), response.redirect_chain) |
187 | 188 | self.assertRedirects(response, '/en/account/register/', 302) |
188 | 189 | |
| 190 | response = self.client.get('/prefixed.xml', HTTP_ACCEPT_LANGUAGE='en', follow=True) |
| 191 | self.assertRedirects(response, '/en/prefixed.xml', 302) |
| 192 | |
189 | 193 | |
190 | 194 | class URLRedirectWithoutTrailingSlashSettingTests(URLTestCaseBase): |
191 | 195 | """ |
diff --git a/tests/regressiontests/i18n/patterns/urls/default.py b/tests/regressiontests/i18n/patterns/urls/default.py
index f117502..00b90b1 100644
a
|
b
|
urlpatterns = patterns('',
|
14 | 14 | |
15 | 15 | urlpatterns += i18n_patterns('', |
16 | 16 | url(r'^prefixed/$', view, name='prefixed'), |
| 17 | url(r'^prefixed\.xml$', view, name='prefixed_xml'), |
17 | 18 | url(_(r'^users/$'), view, name='users'), |
18 | 19 | url(_(r'^account/'), include('regressiontests.i18n.patterns.urls.namespace', namespace='account')), |
19 | 20 | ) |