diff --git a/server.py b/server.py index 33f71f4..d2f3c26 100644 --- a/server.py +++ b/server.py @@ -217,13 +217,15 @@ class VaultHandler(BaseHTTPRequestHandler): params = urllib.parse.parse_qs(query_string) q = params.get("q", [""])[0] self._json({"results": _search(VAULT_DIR, q) if q else []}) - elif path.startswith("/api/vault/file/"): - rel = unquote(path[len("/api/vault/file/"):]) + elif path == "/api/vault/file" or path.startswith("/api/vault/file/"): + if path == "/api/vault/file": + rel = "" + else: + rel = unquote(path[len("/api/vault/file/"):]) # Lukas-add: also support ?file= query for clean URL navigation - if "?" in rel: - rel, _, query = rel.partition("?") + if not rel and query_string: from urllib.parse import parse_qs - file_param = parse_qs(query).get("file", [None])[0] + file_param = parse_qs(query_string).get("file", [None])[0] if file_param: rel = file_param file_path = VAULT_DIR / rel