mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add search params to redirects
This commit is contained in:
parent
055a500851
commit
399157b08d
1 changed files with 13 additions and 2 deletions
|
@ -1,17 +1,28 @@
|
|||
import React from 'react';
|
||||
import { Navigate, Route } from 'react-router-dom';
|
||||
import { Navigate, Route, useLocation } from 'react-router-dom';
|
||||
|
||||
export interface Redirect {
|
||||
from: string
|
||||
to: string
|
||||
}
|
||||
|
||||
const RedirectWithSearch = ({ to }: { to: string }) => {
|
||||
const { search } = useLocation();
|
||||
|
||||
return (
|
||||
<Navigate
|
||||
replace
|
||||
to={`${to}${search}`}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export function toRedirectRoute({ from, to }: Redirect) {
|
||||
return (
|
||||
<Route
|
||||
key={from}
|
||||
path={from}
|
||||
element={<Navigate replace to={to} />}
|
||||
element={<RedirectWithSearch to={to} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue