diff --git a/swh/web/tests/browse/views/test_identifiers.py b/swh/web/tests/browse/views/test_identifiers.py --- a/swh/web/tests/browse/views/test_identifiers.py +++ b/swh/web/tests/browse/views/test_identifiers.py @@ -189,6 +189,16 @@ assert_contains(resp, swhid) + # also check legacy SWHID URL with trailing slash + url = reverse("browse-swhid-legacy", url_args={"swhid": swhid}) + + resp = check_html_get_response(client, url, status_code=302) + resp = check_html_get_response( + client, resp["location"], status_code=200, template_used="browse/content.html" + ) + + assert_contains(resp, swhid) + @given(directory()) def test_browse_swhid_special_characters_escaping(client, archive_data, directory): diff --git a/swh/web/urls.py b/swh/web/urls.py --- a/swh/web/urls.py +++ b/swh/web/urls.py @@ -47,17 +47,17 @@ url(r"^browse/", include("swh.web.browse.urls")), url(r"^$", _default_view, name="swh-web-homepage"), url(r"^jsreverse/$", urls_js, name="js_reverse"), - url( - r"^(?Pswh:[0-9]+:[a-z]+:[0-9a-f]+.*)$", - swhid_browse, - name="browse-swhid", - ), # keep legacy SWHID resolving URL with trailing slash for backward compatibility url( r"^(?Pswh:[0-9]+:[a-z]+:[0-9a-f]+.*)/$", swhid_browse, name="browse-swhid-legacy", ), + url( + r"^(?Pswh:[0-9]+:[a-z]+:[0-9a-f]+.*)$", + swhid_browse, + name="browse-swhid", + ), url(r"^", include("swh.web.misc.urls")), url(r"^", include("swh.web.auth.views")), url(r"^logout/$", LogoutView.as_view(template_name="logout.html"), name="logout"),