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
|
// Create zip entry - use relative path within the folder
|
||||||
relativePath := strings.TrimPrefix(fileToZip.Path, file.Path)
|
relativePath := strings.TrimPrefix(fileToZip.Path, file.Path)
|
||||||
if strings.HasPrefix(relativePath, "/") {
|
if after, ok := strings.CutPrefix(relativePath, "/"); ok {
|
||||||
relativePath = strings.TrimPrefix(relativePath, "/")
|
relativePath = after
|
||||||
}
|
}
|
||||||
|
|
||||||
zipFile, err := zipWriter.Create(relativePath)
|
zipFile, err := zipWriter.Create(relativePath)
|
||||||
|
|||||||
Reference in New Issue
Block a user