diff --git a/swh/web/browse/views/content.py b/swh/web/browse/views/content.py --- a/swh/web/browse/views/content.py +++ b/swh/web/browse/views/content.py @@ -38,7 +38,7 @@ try: reencode = bool(strtobool(request.GET.get('reencode', 'false'))) algo, checksum = query.parse_hash(query_string) - checksum = hash_to_hex(checksum) + checksum = hash_to_hex(checksum.lower()) content_data = request_content(query_string, max_size=None, reencode=reencode) except Exception as exc: @@ -172,7 +172,7 @@ """ # noqa try: algo, checksum = query.parse_hash(query_string) - checksum = hash_to_hex(checksum) + checksum = hash_to_hex(checksum.lower()) content_data = request_content(query_string, raise_if_unavailable=False) origin_type = request.GET.get('origin_type', None) diff --git a/swh/web/browse/views/directory.py b/swh/web/browse/views/directory.py --- a/swh/web/browse/views/directory.py +++ b/swh/web/browse/views/directory.py @@ -21,8 +21,8 @@ from swh.web.browse.browseurls import browse_route -@browse_route(r'directory/(?P[0-9a-f]+)/', - r'directory/(?P[0-9a-f]+)/(?P.+)/', +@browse_route(r'directory/(?P[0-9a-fA-F]+)/', + r'directory/(?P[0-9a-fA-F]+)/(?P.+)/', view_name='browse-directory') def directory_browse(request, sha1_git, path=None): """Django view for browsing the content of a directory identified @@ -30,7 +30,7 @@ The url that points to it is :http:get:`/browse/directory/(sha1_git)/[(path)/]` """ # noqa - root_sha1_git = sha1_git + root_sha1_git = sha1_git.lower() try: if path: dir_info = service.lookup_directory_with_path(sha1_git, path) diff --git a/swh/web/browse/views/release.py b/swh/web/browse/views/release.py --- a/swh/web/browse/views/release.py +++ b/swh/web/browse/views/release.py @@ -18,7 +18,7 @@ ) -@browse_route(r'release/(?P[0-9a-f]+)/', +@browse_route(r'release/(?P[0-9a-fA-F]+)/', view_name='browse-release') def release_browse(request, sha1_git): """ @@ -31,7 +31,7 @@ release = service.lookup_release(sha1_git) snapshot_context = None origin_info = None - snapshot_id = request.GET.get('snapshot_id', None) + snapshot_id = request.GET.get('snapshot_id', None).lower() origin_type = request.GET.get('origin_type', None) origin_url = request.GET.get('origin_url', None) if not origin_url: diff --git a/swh/web/browse/views/revision.py b/swh/web/browse/views/revision.py --- a/swh/web/browse/views/revision.py +++ b/swh/web/browse/views/revision.py @@ -136,12 +136,13 @@ return mark_safe('\n'.join(changes_msg)) -@browse_route(r'revision/(?P[0-9a-f]+)/diff/', +@browse_route(r'revision/(?P[0-9a-fA-F]+)/diff/', view_name='diff-revision') def _revision_diff(request, sha1_git): """ Browse internal endpoint to compute revision diff """ + sha1_git = sha1_git.lower() try: revision = service.lookup_revision(sha1_git) snapshot_context = None @@ -174,7 +175,7 @@ NB_LOG_ENTRIES = 100 -@browse_route(r'revision/(?P[0-9a-f]+)/log/', +@browse_route(r'revision/(?P[0-9a-fA-F]+)/log/', view_name='browse-revision-log') def revision_log_browse(request, sha1_git): """ @@ -183,6 +184,7 @@ The url that points to it is :http:get:`/browse/revision/(sha1_git)/log/` """ # noqa + sha1_git = sha1_git.lower() try: per_page = int(request.GET.get('per_page', NB_LOG_ENTRIES)) offset = int(request.GET.get('offset', 0)) @@ -252,8 +254,8 @@ 'swh_ids': None}) -@browse_route(r'revision/(?P[0-9a-f]+)/', - r'revision/(?P[0-9a-f]+)/(?P.+)/', +@browse_route(r'revision/(?P[0-9a-fA-F]+)/', + r'revision/(?P[0-9a-fA-F]+)/(?P.+)/', view_name='browse-revision') def revision_browse(request, sha1_git, extra_path=None): """ @@ -262,6 +264,7 @@ The url that points to it is :http:get:`/browse/revision/(sha1_git)/`. """ + sha1_git = sha1_git.lower() try: revision = service.lookup_revision(sha1_git) # some readme files can reference assets reachable from the diff --git a/swh/web/browse/views/snapshot.py b/swh/web/browse/views/snapshot.py --- a/swh/web/browse/views/snapshot.py +++ b/swh/web/browse/views/snapshot.py @@ -16,21 +16,23 @@ ) -@browse_route(r'snapshot/(?P[0-9a-f]+)/', +@browse_route(r'snapshot/(?P[0-9a-fA-F]+)/', view_name='browse-snapshot') def snapshot_browse(request, snapshot_id): """Django view for browsing the content of a snapshot. The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/` """ + snapshot_id = snapshot_id.lower() browse_snapshot_url = reverse('browse-snapshot-directory', url_args={'snapshot_id': snapshot_id}, query_params=request.GET) return redirect(browse_snapshot_url) -@browse_route(r'snapshot/(?P[0-9a-f]+)/directory/', - r'snapshot/(?P[0-9a-f]+)/directory/(?P.+)/', +@browse_route(r'snapshot/(?P[0-9a-fA-F]+)/directory/', + r'''snapshot/(?P[0-9a-fA-F]+ + )/directory/(?P.+)/''', view_name='browse-snapshot-directory') def snapshot_directory_browse(request, snapshot_id, path=None): """Django view for browsing the content of a directory collected @@ -38,6 +40,7 @@ The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/directory/[(path)/]` """ # noqa + snapshot_id = snapshot_id.lower() origin_type = request.GET.get('origin_type', None) origin_url = request.GET.get('origin_url', None) if not origin_url: @@ -47,7 +50,7 @@ origin_url=origin_url) -@browse_route(r'snapshot/(?P[0-9a-f]+)/content/(?P.+)/', +@browse_route(r'snapshot/(?P[0-9a-fA-F]+)/content/(?P.+)/', view_name='browse-snapshot-content') def snapshot_content_browse(request, snapshot_id, path): """Django view that produces an HTML display of a content @@ -55,10 +58,11 @@ The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/content/(path)/` """ # noqa + snapshot_id = snapshot_id.lower() return browse_snapshot_content(request, snapshot_id=snapshot_id, path=path) -@browse_route(r'snapshot/(?P[0-9a-f]+)/log/', +@browse_route(r'snapshot/(?P[0-9a-fA-F]+)/log/', view_name='browse-snapshot-log') def snapshot_log_browse(request, snapshot_id): """Django view that produces an HTML display of revisions history (aka @@ -66,10 +70,11 @@ The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/log/` """ # noqa + snapshot_id = snapshot_id.lower() return browse_snapshot_log(request, snapshot_id=snapshot_id) -@browse_route(r'snapshot/(?P[0-9a-f]+)/branches/', +@browse_route(r'snapshot/(?P[0-9a-fA-F]+)/branches/', view_name='browse-snapshot-branches') def snapshot_branches_browse(request, snapshot_id): """Django view that produces an HTML display of the list of releases @@ -77,10 +82,11 @@ The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/branches/` """ # noqa + snapshot_id = snapshot_id.lower() return browse_snapshot_branches(request, snapshot_id=snapshot_id) -@browse_route(r'snapshot/(?P[0-9a-f]+)/releases/', +@browse_route(r'snapshot/(?P[0-9a-fA-F]+)/releases/', view_name='browse-snapshot-releases') def snapshot_releases_browse(request, snapshot_id): """Django view that produces an HTML display of the list of releases @@ -88,4 +94,5 @@ The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/releases/` """ # noqa + snapshot_id = snapshot_id.lower() return browse_snapshot_releases(request, snapshot_id=snapshot_id)