From e3a38efb224c5a498bdb9f4905c77f3fb417f1a8 Mon Sep 17 00:00:00 2001 From: lavirlifiliol Date: Sun, 7 Jul 2024 18:52:22 +0200 Subject: [PATCH] fix: create path correctly (#82) 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)