Refactor prefix trimming in publicFileDownloadHandler for improved clarity
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user