From 3ff33b15f487017e494d8fc32c059abf57128507 Mon Sep 17 00:00:00 2001 From: Adam Hrbac Date: Fri, 5 Jul 2024 08:38:15 +0200 Subject: [PATCH] fix: create path correctly Doing string manipulation breaks with queries in url. --- api/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/main.py b/api/main.py index 8cc6311..36e1f71 100644 --- a/api/main.py +++ b/api/main.py @@ -36,8 +36,8 @@ def dicthash(data: dict) -> str: def make_file_path(dh: str, request_url: URL) -> str: """Build a file path from dict_hash and a URL.""" - fqdn = str(request_url).removesuffix(request_url.path) - return f"{fqdn}/static/{dh}.png" + path = f"/static/{dh}.png" + return str(request_url.replace(query="", path=path)) @app.get("/duck", status_code=201)