diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-03 17:53:30 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-03 17:53:30 +0800 |
commit | e2a6d73b940bd2a222747f777efc37c3b04b1d16 (patch) | |
tree | 784dc0f20336a39ce4d0709a8ccb778a5e248b83 /http_server.go | |
parent | HTTP: Ref type query errors should be 400, not 500 (diff) | |
download | forge-0.1.12.tar.gz forge-0.1.12.tar.zst forge-0.1.12.zip |
HTML: Use the proper repo_url_root in tree/rawtreev0.1.12
Diffstat (limited to 'http_server.go')
-rw-r--r-- | http_server.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/http_server.go b/http_server.go index 722ac81..0a474cc 100644 --- a/http_server.go +++ b/http_server.go @@ -6,6 +6,7 @@ package main import ( "errors" "net/http" + "net/url" "strconv" "strings" @@ -184,6 +185,12 @@ func (router *forgeHTTPRouter) ServeHTTP(writer http.ResponseWriter, request *ht 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) { return |