mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 03:22:11 +00:00
Merge 2de2e89446 into cf73c7942d
This commit is contained in:
commit
63e26d8211
4 changed files with 16 additions and 3 deletions
|
|
@ -16,6 +16,10 @@ const EpisodePicker = ({ className, onSubmit }: Props) => {
|
||||||
|
|
||||||
const { initialSeason, initialEpisode } = useMemo(() => {
|
const { initialSeason, initialEpisode } = useMemo(() => {
|
||||||
const splitPath = window.location.hash.split('/');
|
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 videoId = decodeURIComponent(splitPath[splitPath.length - 1]);
|
||||||
const [, pathSeason, pathEpisode] = videoId ? videoId.split(':') : [];
|
const [, pathSeason, pathEpisode] = videoId ? videoId.split(':') : [];
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,11 @@ const MetaDetails = ({ urlParams, queryParams }) => {
|
||||||
const handleEpisodeSearch = React.useCallback((season, episode) => {
|
const handleEpisodeSearch = React.useCallback((season, episode) => {
|
||||||
const searchVideoHash = encodeURIComponent(`${urlParams.id}:${season}:${episode}`);
|
const searchVideoHash = encodeURIComponent(`${urlParams.id}:${season}:${episode}`);
|
||||||
const url = window.location.hash;
|
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;
|
window.location = searchVideoPath;
|
||||||
}, [urlParams, window.location]);
|
}, [urlParams, window.location]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ const useMetaDetails = (urlParams) => {
|
||||||
id: urlParams.id,
|
id: urlParams.id,
|
||||||
extra: []
|
extra: []
|
||||||
},
|
},
|
||||||
streamPath: typeof urlParams.videoId === 'string' ?
|
streamPath: typeof urlParams.videoId === 'string' && urlParams.videoId !== '' ?
|
||||||
{
|
{
|
||||||
resource: 'stream',
|
resource: 'stream',
|
||||||
type: urlParams.type,
|
type: urlParams.type,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,12 @@ const useSeason = (urlParams, queryParams) => {
|
||||||
const setSeason = React.useCallback((season) => {
|
const setSeason = React.useCallback((season) => {
|
||||||
const nextQueryParams = new URLSearchParams(queryParams);
|
const nextQueryParams = new URLSearchParams(queryParams);
|
||||||
nextQueryParams.set('season', season);
|
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]);
|
}, [urlParams, queryParams]);
|
||||||
return [season, setSeason];
|
return [season, setSeason];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue