mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-27 17:38:51 +05:00
fix(images): decode path early and treat decoded placeholder; handle absolute URLs reliably
This commit is contained in:
@@ -28,7 +28,13 @@ func (h *ImagesHandler) GetImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
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)
|
h.servePlaceholder(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -39,11 +45,9 @@ func (h *ImagesHandler) GetImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var imageURL string
|
var imageURL string
|
||||||
if strings.HasPrefix(imagePath, "http://") || strings.HasPrefix(imagePath, "https://") {
|
if strings.HasPrefix(decodedPath, "http://") || strings.HasPrefix(decodedPath, "https://") {
|
||||||
// Проксируем внешний абсолютный URL (например, Kinopoisk)
|
// Проксируем внешний абсолютный URL (например, Kinopoisk)
|
||||||
// Поддержим случай, когда на фронте параметр уже был url-encoded
|
imageURL = decodedPath
|
||||||
decoded, _ := url.QueryUnescape(imagePath)
|
|
||||||
imageURL = decoded
|
|
||||||
} else {
|
} else {
|
||||||
// TMDB относительный путь
|
// TMDB относительный путь
|
||||||
imageURL = fmt.Sprintf("%s/%s/%s", config.TMDBImageBaseURL, size, imagePath)
|
imageURL = fmt.Sprintf("%s/%s/%s", config.TMDBImageBaseURL, size, imagePath)
|
||||||
|
|||||||
Reference in New Issue
Block a user