NextExpense/internal/handlers/helpers.go
cclohmar 0b55ac1fac fix: normalize ImagePath for old database entries with storage/ prefix
- Added normalizeImagePath() helper that strips legacy storage/ prefix
- Applied in ViewEventExpenses, SaveExpense, UpdateExpense, EditExpense
- Prevents double storage/storage/ in image URLs for old expenses
2026-06-01 23:30:56 +00:00

10 lines
357 B
Go

package handlers
import "strings"
// normalizeImagePath strips a legacy "storage/" prefix if present, so that
// the template can safely build "/storage/{filename}" URLs regardless of
// whether the database entry was stored as "uuid.jpg" or "storage/uuid.jpg".
func normalizeImagePath(path string) string {
return strings.TrimPrefix(path, "storage/")
}