simplify SplitNameExt

This commit is contained in:
orangix
2026-01-31 05:19:02 +01:00
parent d84ca93e0e
commit 4ffe09bb81
4 changed files with 11 additions and 19 deletions

View File

@@ -87,7 +87,7 @@ func main() {
app.Handle("GET /t/{tag}", wrapHandler(func(w http.ResponseWriter, r *http.Request) error {
name, ext := utils.SplitNameExt(r.PathValue("tag"))
if ext != "" {
r.SetPathValue("tag", name[0:len(name)-1])
r.SetPathValue("tag", name)
r.SetPathValue("type", ext)
return pages.HandleTagRSS(w, r)
}
@@ -98,7 +98,7 @@ func main() {
app.Handle("GET /user/{userID}", wrapHandler(func(w http.ResponseWriter, r *http.Request) error {
name, ext := utils.SplitNameExt(r.PathValue("userID"))
if ext != "" {
r.SetPathValue("userID", name[0:len(name)-1])
r.SetPathValue("userID", name)
r.SetPathValue("type", ext)
return pages.HandleUserRSS(w, r)
}
@@ -133,7 +133,7 @@ func main() {
r.SetPathValue("baseName", baseName)
r.SetPathValue("extension", extension)
switch extension {
case "png", "gif", "jpg", "jpeg", "webp", "mp4", "webm":
case ".png", ".gif", ".jpg", ".jpeg", ".webp", ".mp4", ".webm":
return pages.HandleMedia(w, r)
}
fallthrough