From e2a6d73b940bd2a222747f777efc37c3b04b1d16 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 03 Apr 2025 17:53:30 +0800 Subject: [PATCH] HTML: Use the proper repo_url_root in tree/rawtree --- http_server.go | 7 +++++++ templates/repo_raw_dir.tmpl | 14 +++++++------- templates/repo_tree_dir.tmpl | 14 +++++++------- diff --git a/http_server.go b/http_server.go index 722ac81d24e1aadb909255487899a9e305a95a88..0a474ccfcb283e2a36f8889c76e43ae1be6aafa1 100644 --- a/http_server.go +++ b/http_server.go @@ -6,6 +6,7 @@ import ( "errors" "net/http" + "net/url" "strconv" "strings" @@ -183,6 +184,12 @@ if params["repo"], params["repo_description"], params["repo_id"], _, err = openRepo(request.Context(), groupPath, moduleName); err != nil { errorPage500(writer, params, "Error opening repo: "+err.Error()) return } + + repoURLRoot := "/" + for _, part := range segments[:sepIndex+3] { + repoURLRoot = repoURLRoot + url.PathEscape(part) + "/" + } + params["repo_url_root"] = repoURLRoot if len(segments) == sepIndex+3 { if redirectDir(writer, request) { diff --git a/templates/repo_raw_dir.tmpl b/templates/repo_raw_dir.tmpl index c0df8fd118751fef7fb0b63be6795dabc87fbe3b..4072326b7186768db254b8a217531c1f24553695 100644 --- a/templates/repo_raw_dir.tmpl +++ b/templates/repo_raw_dir.tmpl @@ -16,25 +16,25 @@

{{- .repo_name -}}

diff --git a/templates/repo_tree_dir.tmpl b/templates/repo_tree_dir.tmpl index 3f430645e7d6cb2002f7913ab7adb6dc89ccea57..c528fee887a9cea36ee5225b62fcff2fa35b87e9 100644 --- a/templates/repo_tree_dir.tmpl +++ b/templates/repo_tree_dir.tmpl @@ -16,25 +16,25 @@

{{- .repo_name -}}

-- 2.48.1