From 2237e27308c715fc7098c164e748e7efd30e14ee Mon Sep 17 00:00:00 2001 From: Erno Date: Sun, 19 Oct 2025 17:12:52 +0000 Subject: [PATCH] fix(images): decode path early and treat decoded placeholder; handle absolute URLs reliably --- pkg/handlers/images.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/handlers/images.go b/pkg/handlers/images.go index 23317de..51d51f5 100644 --- a/pkg/handlers/images.go +++ b/pkg/handlers/images.go @@ -28,7 +28,13 @@ func (h *ImagesHandler) GetImage(w http.ResponseWriter, r *http.Request) { return } - if imagePath == "placeholder.jpg" { + // Попробуем декодировать путь заранее (на фронте абсолютные URL передаются как encodeURIComponent) + decodedPath := imagePath + if dp, err := url.QueryUnescape(imagePath); err == nil { + decodedPath = dp + } + + if imagePath == "placeholder.jpg" || decodedPath == "placeholder.jpg" { h.servePlaceholder(w, r) return } @@ -39,11 +45,9 @@ func (h *ImagesHandler) GetImage(w http.ResponseWriter, r *http.Request) { } var imageURL string - if strings.HasPrefix(imagePath, "http://") || strings.HasPrefix(imagePath, "https://") { + if strings.HasPrefix(decodedPath, "http://") || strings.HasPrefix(decodedPath, "https://") { // Проксируем внешний абсолютный URL (например, Kinopoisk) - // Поддержим случай, когда на фронте параметр уже был url-encoded - decoded, _ := url.QueryUnescape(imagePath) - imageURL = decoded + imageURL = decodedPath } else { // TMDB относительный путь imageURL = fmt.Sprintf("%s/%s/%s", config.TMDBImageBaseURL, size, imagePath)