fix: prevent double encode if we are on /search endpoint (#3238)

This commit is contained in:
Brandon Cohen
2023-01-13 18:21:54 -05:00
committed by GitHub
parent c2a1a20a3b
commit a343f8ad91
7 changed files with 25 additions and 28 deletions

View File

@@ -1,4 +1,3 @@
import { encodeURIExtraParams } from '@app/hooks/useSearchInput';
import { MediaStatus } from '@server/constants/media';
import useSWRInfinite from 'swr/infinite';
import useSettings from './useSettings';
@@ -28,6 +27,23 @@ interface DiscoverResult<T, S> {
firstResultData?: BaseSearchResult<T> & S;
}
const extraEncodes: [RegExp, string][] = [
[/\(/g, '%28'],
[/\)/g, '%29'],
[/!/g, '%21'],
[/\*/g, '%2A'],
];
export const encodeURIExtraParams = (string: string): string => {
let finalString = encodeURIComponent(string);
extraEncodes.forEach((encode) => {
finalString = finalString.replace(encode[0], encode[1]);
});
return finalString;
};
const useDiscover = <
T extends BaseMedia,
S = Record<string, never>,