1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Add legacy bang url redirects

This commit is contained in:
Bill Thornton 2024-07-24 15:12:33 -04:00
parent dce7a36fcf
commit ba8fb5eb81
3 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1,34 @@
import React, { useMemo } from 'react';
import { Navigate, useLocation } from 'react-router-dom';
const BangRedirect = () => {
const location = useLocation();
const to = useMemo(() => {
const _to = {
search: location.search,
hash: location.hash
};
if (location.pathname.startsWith('/!/')) {
return { ..._to, pathname: location.pathname.substring(2) };
} else if (location.pathname.startsWith('/!')) {
return { ..._to, pathname: location.pathname.replace(/^\/!/, '/') };
} else if (location.pathname.startsWith('!')) {
return { ..._to, pathname: location.pathname.substring(1) };
}
}, [ location ]);
if (!to) return null;
console.warn('[BangRedirect] You are using a deprecated URL format. This will stop working in a future Jellyfin update.');
return (
<Navigate
replace
to={to}
/>
);
};
export default BangRedirect;