bugs after refactor

This commit is contained in:
Arnas Udovic 2024-07-11 16:29:17 +03:00
parent d9602f5c48
commit 712d35ae4d

22
main.go
View file

@ -140,22 +140,22 @@ func process(_ context.Context, w gemini.ResponseWriter, r *gemini.Request) {
renderFeed(w, r, client) renderFeed(w, r, client)
case regexp.MustCompile(`^/a/?$`).MatchString(r.URL.Path): case regexp.MustCompile(`^/a/?$`).MatchString(r.URL.Path):
renderAbout(w) renderAbout(w)
case regexp.MustCompile(`^/(` + langs + `)/s/?$`).MatchString(r.URL.Path): case regexp.MustCompile(`^/s/?$`).MatchString(r.URL.Path):
renderSearch(lang, w, r, client) renderSearch(w, r, client)
case regexp.MustCompile(`^/(` + langs + `)/f/?$`).MatchString(r.URL.Path): case regexp.MustCompile(`^/f/?$`).MatchString(r.URL.Path):
renderAllFiles(lang, w, client) renderAllFiles(w, client)
case regexp.MustCompile(`^/(` + langs + `)/f/([\p{L}\d_+.]+/)+[\d\w]+/index.gmi$`).MatchString(r.URL.Path): case regexp.MustCompile(`^/f/([\p{L}\d_+.]+/)+[\d\w]+/index.gmi$`).MatchString(r.URL.Path):
urlParts := strings.Split(r.URL.Path, "/") urlParts := strings.Split(r.URL.Path, "/")
w.WriteHeader( w.WriteHeader(
gemini.StatusPermanentRedirect, gemini.StatusPermanentRedirect,
strings.Join(urlParts[:(len(urlParts)-2)], "/"), strings.Join(urlParts[:(len(urlParts)-2)], "/"),
) )
case regexp.MustCompile(`^/(` + langs + `)/f/([\p{L}\d_+.]+/)+[\d\w]+/[\p{L}\d_+.]+.gmi$`).MatchString(r.URL.Path): case regexp.MustCompile(`^/f/([\p{L}\d_+.]+/)+[\d\w]+/[\p{L}\d_+.]+.gmi$`).MatchString(r.URL.Path):
renderFile(lang, w, r, client) renderFile(w, r, client)
case regexp.MustCompile(`^/(` + langs + `)/f/[\p{L}\d_+.]+(/[\p{L}\d_+.]+)*/?$`).MatchString(r.URL.Path): case regexp.MustCompile(`^/f/[\p{L}\d_+.]+(/[\p{L}\d_+.]+)*/?$`).MatchString(r.URL.Path):
renderCategory(lang, w, r, client) renderCategory(w, r, client)
case regexp.MustCompile(`^/(` + langs + `)/t/[\p{L}\d_+.]+/?$`).MatchString(r.URL.Path): case regexp.MustCompile(`^/t/[\p{L}\d_+.]+/?$`).MatchString(r.URL.Path):
renderTag(lang, w, r, client) renderTag(w, r, client)
case regexp.MustCompile(`^/__a/`).MatchString(r.URL.Path): case regexp.MustCompile(`^/__a/`).MatchString(r.URL.Path):
downloadAttachment(w, r, client) downloadAttachment(w, r, client)
default: default: