~edwargix/git.sr.ht

e322fdba14284e6dc170b9a2679783016bafcd61 — Gregory Mullen 7 years ago 5a4a9a9
Remove duplicate paths from flask routes
1 files changed, 4 insertions(+), 7 deletions(-)

M gitsrht/blueprints/public.py
M gitsrht/blueprints/public.py => gitsrht/blueprints/public.py +4 -7
@@ 37,10 37,9 @@ def check_repo(user, repo, authorized=current_user):
            abort(404)
    return u, _repo

@public.route("/<owner_name>/<repo_name>", defaults={ "cgit_path": "" })
@public.route("/<owner_name>/<repo_name>/", defaults={ "cgit_path": "" })
@public.route("/<owner_name>/<repo_name>")
@public.route("/<owner_name>/<repo_name>/<path:cgit_path>")
def cgit_passthrough(owner_name, repo_name, cgit_path):
def cgit_passthrough(owner_name, repo_name, cgit_path=""):
    owner, repo = get_repo(owner_name, repo_name)
    if isinstance(repo, Redirect):
        return redirect(url_for(".cgit_passthrough",


@@ 77,11 76,9 @@ def cgit_passthrough(owner_name, repo_name, cgit_path):
            cgit_html=text, owner=owner, repo=repo,
            has_access=has_access, UserAccess=UserAccess)

@public.route("/<owner_name>/<repo_name>/<op>", defaults={"path": None})
@public.route("/<owner_name>/<repo_name>/<op>")
@public.route("/<owner_name>/<repo_name>/<op>/<path:path>")
@public.route("/<owner_name>/<repo_name>/<op>/<path:path>")
@public.route("/<owner_name>/<repo_name>/<op>/<path:path>")
def cgit_plain(owner_name, repo_name, op, path):
def cgit_plain(owner_name, repo_name, op, path=None):
    if not op in ["patch", "plain", "snapshot"]:
        return cgit_passthrough(owner_name, repo_name,
                op + ("/" + path if path else ""))