From e1fe33ce46a5ec38197d389c3b9123ec0b375982 Mon Sep 17 00:00:00 2001 From: Arnas Udovic Date: Thu, 11 Jul 2024 23:48:31 +0300 Subject: [PATCH] url path fix --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 5cd964e..f62e2b4 100644 --- a/main.go +++ b/main.go @@ -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)-2)], "/"), + strings.Join(urlParts[:(len(urlParts)-1)], "/"), ) case regexp.MustCompile(`^/f/([\p{L}\d_+.]+/)+[\d\w]+/[\p{L}\d_+.]+.gmi$`).MatchString(r.URL.Path): renderFile(w, r, client) @@ -347,7 +347,7 @@ func renderCategory( client TreeManagerClient, ) { urlParts := strings.Split(strings.Trim(r.URL.Path, "/"), "/") - path := "/" + strings.Join(urlParts[2:], "/") + path := "/" + strings.Join(urlParts[1:], "/") tr := TreeRequest{Path: &path, Filter: []*TreeRequest_Filter{}} @@ -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)-1] + tag := urlParts[len(urlParts)] tagFilter := TreeRequest_Filter{Key: "tag", Value: tag} filters := []*TreeRequest_Filter{&tagFilter}