url path fix #2

This commit is contained in:
Arnas Udovic 2024-07-12 00:00:07 +03:00
parent e1fe33ce46
commit 81c5db91f3

View file

@ -148,7 +148,7 @@ func process(_ context.Context, w gemini.ResponseWriter, r *gemini.Request) {
urlParts := strings.Split(r.URL.Path, "/")
w.WriteHeader(
gemini.StatusPermanentRedirect,
strings.Join(urlParts[:(len(urlParts)-1)], "/"),
strings.Join(urlParts[:(len(urlParts)-2)], "/"),
)
case regexp.MustCompile(`^/f/([\p{L}\d_+.]+/)+[\d\w]+/[\p{L}\d_+.]+.gmi$`).MatchString(r.URL.Path):
renderFile(w, r, client)
@ -439,7 +439,7 @@ func renderAllFiles(w gemini.ResponseWriter, client TreeManagerClient) {
func renderTag(w gemini.ResponseWriter, r *gemini.Request, client TreeManagerClient) {
urlParts := strings.Split(strings.Trim(r.URL.Path, "/"), "/")
tag := urlParts[len(urlParts)]
tag := urlParts[len(urlParts)-1]
tagFilter := TreeRequest_Filter{Key: "tag", Value: tag}
filters := []*TreeRequest_Filter{&tagFilter}