_app.py/json_info: improved error handling
- added redirect if package name is not normalized - raise 404 error if package is not found
This commit is contained in:
parent
a9414fb964
commit
c205355253
|
@ -366,10 +366,19 @@ def server_static(filename):
|
|||
@app.route("/:project/json")
|
||||
@auth("list")
|
||||
def json_info(project):
|
||||
# PEP 503: require normalized project
|
||||
normalized = normalize_pkgname_for_url(project)
|
||||
if project != normalized:
|
||||
return redirect(f"/{normalized}/json", 301)
|
||||
|
||||
packages = sorted(
|
||||
config.backend.find_project_packages(project),
|
||||
key=lambda x: x.parsed_version, reverse=True
|
||||
)
|
||||
|
||||
if not packages:
|
||||
raise HTTPError(404, f"package {project} not found")
|
||||
|
||||
latest_version = packages[0].version
|
||||
releases = {}
|
||||
req_url = request.url
|
||||
|
|
Loading…
Reference in New Issue