diff --git a/swh/web/common/archive.py b/swh/web/common/archive.py --- a/swh/web/common/archive.py +++ b/swh/web/common/archive.py @@ -248,6 +248,9 @@ # slash while the url in storage have it (e.g. Debian source package) else: origin_urls.append(f"{origin['url']}/") + # handle case where the "://" character sequence was mangled into ":/" + if ":/" in origin["url"] and "://" not in origin["url"]: + origin_urls.append(origin["url"].replace(":/", "://")) origins = [o for o in storage.origin_get(origin_urls) if o is not None] if not origins: msg = "Origin with url %s not found!" % origin["url"] diff --git a/swh/web/tests/common/test_archive.py b/swh/web/tests/common/test_archive.py --- a/swh/web/tests/common/test_archive.py +++ b/swh/web/tests/common/test_archive.py @@ -975,6 +975,14 @@ assert origin_info["url"] == deb_origin.url +def test_lookup_origin_single_slash_after_protocol(archive_data): + url = "http://snapshot.debian.org/package/r-base/" + deb_origin = Origin(url=url) + archive_data.origin_add([deb_origin]) + origin_info = archive.lookup_origin({"url": url.replace("://", ":/")}) + assert origin_info["url"] == deb_origin.url + + @given(snapshot()) def test_lookup_snapshot_branch_name_from_tip_revision(archive_data, snapshot_id): snapshot = archive_data.snapshot_get(snapshot_id)