diff --git a/assets/src/bundles/browse/swhid-utils.js b/assets/src/bundles/browse/swhid-utils.js --- a/assets/src/bundles/browse/swhid-utils.js +++ b/assets/src/bundles/browse/swhid-utils.js @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2019 The Software Heritage developers + * Copyright (C) 2018-2021 The Software Heritage developers * See the AUTHORS file at the top-level directory of this distribution * License: GNU Affero General Public License version 3, or any later version * See top-level LICENSE file for more information @@ -30,7 +30,7 @@ if (pos !== -1) { currentSwhId = currentSwhId.slice(0, pos); } - swhIdElt.attr('href', '/' + currentSwhId + '/'); + swhIdElt.attr('href', '/' + currentSwhId); } swhIdElt.text(currentSwhId); @@ -62,7 +62,7 @@ } swhIdElt.text(currentSwhId.replace(/;/g, ';\n')); - swhIdElt.attr('href', '/' + currentSwhId + '/'); + swhIdElt.attr('href', '/' + currentSwhId); } } diff --git a/swh/web/tests/common/test_identifiers.py b/swh/web/tests/common/test_identifiers.py --- a/swh/web/tests/common/test_identifiers.py +++ b/swh/web/tests/common/test_identifiers.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020 The Software Heritage developers +# Copyright (C) 2020-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -433,7 +433,7 @@ # check special characters in SWHID URL have been escaped parsed_url_swhid = QualifiedSWHID.from_string( - swhid_info["swhid_with_context_url"][1:-1] + swhid_info["swhid_with_context_url"][1:] ) assert ( parsed_url_swhid.qualifiers()["origin"] diff --git a/swh/web/urls.py b/swh/web/urls.py --- a/swh/web/urls.py +++ b/swh/web/urls.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2020 The Software Heritage developers +# Copyright (C) 2017-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -48,10 +48,16 @@ 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]+.*)/$", + 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"^", include("swh.web.misc.urls")), url(r"^", include("swh.web.auth.views")), url(r"^logout/$", LogoutView.as_view(template_name="logout.html"), name="logout"),