Revert "Fix #11890: Append slash at locale root URL"

This reverts commit 89ed50238a.
This commit is contained in:
Paul McLanahan 2022-07-21 09:58:55 -04:00 коммит произвёл Paul McLanahan
Родитель d4920b3fa7
Коммит bcd61a8a61
2 изменённых файлов: 1 добавлений и 6 удалений

Просмотреть файл

@ -166,10 +166,7 @@ def render(request, template, context=None, ftl_files=None, activation_files=Non
# Does that path's locale match the request's locale?
if locale in translations:
# Redirect to the locale if:
# - The URL is the root path but is missing the trailing slash OR
# - The locale isn't in current prefix in the URL.
if request.path == f"/{locale}" or locale != request.path.lstrip("/").partition("/")[0]:
if locale != request.path.lstrip("/").partition("/")[0]:
return redirect_to_locale(request, locale)
else:
return redirect_to_best_locale(request, translations)

Просмотреть файл

@ -62,8 +62,6 @@ class TestRender(TestCase):
self._test("/firefox/new/", template, "", "", 404, active_locales=locales)
# Test that a locale+path and no accept language header returns 200 as long as the locales are supported.
self._test("/en-US", template, "", "", 302, "/en-US/", active_locales=locales)
self._test("/en-US/", template, "", "", 200, active_locales=locales)
self._test("/en-US/firefox/new/", template, "", "", 200, active_locales=locales)
self._test("/en-GB/firefox/new/", template, "", "", 200, active_locales=locales)
self._test("/fr/firefox/new/", template, "", "", 200, active_locales=locales)