Skip to content

Commit

Permalink
api: redirect double slashes
Browse files Browse the repository at this point in the history
This was an issue in the past where people would set the upgrade server
URL to something with a trailing slash, resulting requests containing a
duplicate slash.

Redirect double slashes to single slashes to solve the issue.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Aug 9, 2024
1 parent 5376bf0 commit cda6f5a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion asu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ def json_v1_arch_index(path: str, arch: str):
return packages


app.mount("/json", StaticFiles(directory=settings.public_path / "json"), name="json")
app.mount(
"/json",
StaticFiles(directory=settings.public_path / "json"),
name="json",
)


@app.get("//{path:path}")
def api_double_slash(path: str):
print(f"Redirecting double slash to single slash: {path}")
return RedirectResponse(f"/{path}", status_code=301)


# very legacy
Expand Down

0 comments on commit cda6f5a

Please sign in to comment.