This commit is contained in:
Lachezar Lechev 2026-01-10 00:52:31 +01:00 committed by GitHub
commit 744d8dbfa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View file

@ -16,6 +16,10 @@ const EpisodePicker = ({ className, onSubmit }: Props) => {
const { initialSeason, initialEpisode } = useMemo(() => {
const splitPath = window.location.hash.split('/');
if (splitPath[splitPath.length - 1] === '') {
// remove the empty element
splitPath.pop();
}
const videoId = decodeURIComponent(splitPath[splitPath.length - 1]);
const [, pathSeason, pathEpisode] = videoId ? videoId.split(':') : [];
return {

View file

@ -81,7 +81,11 @@ const MetaDetails = ({ urlParams, queryParams }) => {
const handleEpisodeSearch = React.useCallback((season, episode) => {
const searchVideoHash = encodeURIComponent(`${urlParams.id}:${season}:${episode}`);
const url = window.location.hash;
const searchVideoPath = url.replace(encodeURIComponent(urlParams.videoId), searchVideoHash);
const searchVideoPath = (urlParams.videoId === undefined || urlParams.videoId === null || urlParams.videoId === '') ?
url + (!url.endsWith('/') ? '/' : '') + searchVideoHash
: url.replace(encodeURIComponent(urlParams.videoId), searchVideoHash);
window.location = searchVideoPath;
}, [urlParams, window.location]);

View file

@ -48,7 +48,7 @@ const useMetaDetails = (urlParams) => {
id: urlParams.id,
extra: []
},
streamPath: typeof urlParams.videoId === 'string' ?
streamPath: typeof urlParams.videoId === 'string' && urlParams.videoId !== '' ?
{
resource: 'stream',
type: urlParams.type,

View file

@ -12,7 +12,12 @@ const useSeason = (urlParams, queryParams) => {
const setSeason = React.useCallback((season) => {
const nextQueryParams = new URLSearchParams(queryParams);
nextQueryParams.set('season', season);
window.location.replace(`#${urlParams.path}?${nextQueryParams}`);
const path = urlParams.path.endsWith('/') ?
// remove the trailing /
urlParams.path.slice(0, -1):
urlParams.path;
window.location.replace(`#${path}?${nextQueryParams}`);
}, [urlParams, queryParams]);
return [season, setSeason];
};