fix: clamp watch route to final episode

This commit is contained in:
2026-04-18 23:57:14 +02:00
parent 2849a91736
commit 70ed0b5716

View File

@@ -79,6 +79,14 @@ func (h *Handler) HandleWatchPage(w http.ResponseWriter, r *http.Request) {
return
}
if anime.Episodes > 0 {
episodeNumber, parseErr := strconv.Atoi(episode)
if parseErr == nil && episodeNumber > anime.Episodes {
http.Redirect(w, r, "/watch/"+strconv.Itoa(malID)+"/"+strconv.Itoa(anime.Episodes), http.StatusFound)
return
}
}
title := anime.DisplayTitle()
userID := watchlistUserIDFromRequest(r)
data, err := h.svc.BuildWatchPageData(ctx, malID, title, episode, mode, userID)