mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix legacy URL redirect
This commit is contained in:
parent
061db56fa7
commit
fe64fe5be0
1 changed files with 12 additions and 4 deletions
|
@ -2,8 +2,6 @@ import { Update } from 'history';
|
||||||
import { useLayoutEffect, useState } from 'react';
|
import { useLayoutEffect, useState } from 'react';
|
||||||
import type { History, Router } from '@remix-run/router';
|
import type { History, Router } from '@remix-run/router';
|
||||||
|
|
||||||
const normalizePath = (pathname: string) => pathname.replace(/^!/, '');
|
|
||||||
|
|
||||||
interface UseLegacyRouterSyncProps {
|
interface UseLegacyRouterSyncProps {
|
||||||
router: Router;
|
router: Router;
|
||||||
history: History;
|
history: History;
|
||||||
|
@ -20,8 +18,18 @@ export function useLegacyRouterSync({ router, history }: UseLegacyRouterSyncProp
|
||||||
* implementation, so we need to remove the leading `!` from the pathname. React Router already removes the
|
* implementation, so we need to remove the leading `!` from the pathname. React Router already removes the
|
||||||
* hash for us.
|
* hash for us.
|
||||||
*/
|
*/
|
||||||
if (update.location.pathname.startsWith('!')) {
|
if (update.location.pathname.startsWith('/!/')) {
|
||||||
history.replace(normalizePath(update.location.pathname), update.location.state);
|
history.replace(
|
||||||
|
{ ...update.location, pathname: update.location.pathname.replace(/^\/!/, '') },
|
||||||
|
update.location.state);
|
||||||
|
} else if (update.location.pathname.startsWith('/!')) {
|
||||||
|
history.replace(
|
||||||
|
{ ...update.location, pathname: update.location.pathname.replace(/^\/!/, '/') },
|
||||||
|
update.location.state);
|
||||||
|
} else if (update.location.pathname.startsWith('!')) {
|
||||||
|
history.replace(
|
||||||
|
{ ...update.location, pathname: update.location.pathname.replace(/^!/, '') },
|
||||||
|
update.location.state);
|
||||||
} else if (!isSynced) {
|
} else if (!isSynced) {
|
||||||
await router.navigate(update.location, { replace: true });
|
await router.navigate(update.location, { replace: true });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue