fix: meta details - don't set streamPath if videoId is empty string

- fix season selection path inconsistencies

Signed-off-by: Lachezar Lechev <lachezar@ambire.com>
This commit is contained in:
Lachezar Lechev 2025-10-17 14:09:27 +03:00
parent ea69521912
commit 2de2e89446
No known key found for this signature in database
GPG key ID: 69BDCB3ED8CE8037
3 changed files with 11 additions and 2 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

@ -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];
};