Refactor prefix trimming in publicFileDownloadHandler for improved clarity

This commit is contained in:
Leon Bösche
2026-01-29 00:00:14 +01:00
parent f4f80b9ed7
commit 2623b6818f

View File

@@ -3255,8 +3255,8 @@ func publicFileDownloadHandler(w http.ResponseWriter, r *http.Request, db *datab
// Create zip entry - use relative path within the folder
relativePath := strings.TrimPrefix(fileToZip.Path, file.Path)
if strings.HasPrefix(relativePath, "/") {
relativePath = strings.TrimPrefix(relativePath, "/")
if after, ok := strings.CutPrefix(relativePath, "/"); ok {
relativePath = after
}
zipFile, err := zipWriter.Create(relativePath)