From 48dcdbd06de9702795ecc8ebd33bdf6c6345676b Mon Sep 17 00:00:00 2001 From: Nolan Prescott Date: Thu, 17 Dec 2020 23:52:38 -0500 Subject: [PATCH] Allow "path" ref in log and tree URLs This change updates both the //log and //tree URLs by including a sentinel value between the two possible "path"-like parts of the URL, the ref and the path. Without a sentinel value it is not possible to use the two path variables due to the greedy nature of the last instance. Case in point, something like: @route(/) def example(first, second): return f'first: {first} second: {second}' GET debian/0.1.0-2/some/file first: debian second: 0.1.0-2/some/file --- gitsrht/blueprints/repo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index 748ebc1..88e46e7 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -186,7 +186,7 @@ def lookup_ref(git_repo, ref, path): @repo.route("///tree", defaults={"ref": None, "path": ""}) @repo.route("///tree/", defaults={"path": ""}) -@repo.route("///tree//") +@repo.route("///tree//item/") def tree(owner, repo, ref, path): owner, repo = get_repo_or_redir(owner, repo) @@ -394,7 +394,7 @@ def collect_refs(git_repo): @repo.route("///log", defaults={"ref": None, "path": ""}) @repo.route("///log/", defaults={"path": ""}) -@repo.route("///log//") +@repo.route("///log//item/") def log(owner, repo, ref, path): owner, repo = get_repo_or_redir(owner, repo) with GitRepository(repo.path) as git_repo: -- 2.38.4