fix(frontend): allow more special characters in search input

fixes #430
pull/226/head
sct 4 years ago
parent 6753d9daaa
commit 5deb64a87f

@ -1,4 +1,5 @@
import axios, { AxiosInstance } from 'axios';
import logger from '../logger';
export const ANIME_KEYWORD_ID = 210024;
@ -374,7 +375,16 @@ class TheMovieDb {
return response.data;
} catch (e) {
throw new Error(`[TMDB] Failed to search multi: ${e.message}`);
logger.error('Failed to search multi', {
label: 'TMDB',
errorMessage: e.message,
});
return {
page: 1,
results: [],
total_pages: 1,
total_results: 0,
};
}
};

@ -7,8 +7,20 @@ import type { Nullable } from '../utils/typeHelpers';
type Url = string | UrlObject;
const extraEncodes: [RegExp, string][] = [
[/\(/g, '%28'],
[/\)/g, '%29'],
[/!/g, '%21'],
];
const encodeURIExtraParams = (string: string): string => {
return encodeURIComponent(string).replace(/!/g, '%21');
let finalString = encodeURIComponent(string);
extraEncodes.forEach((encode) => {
finalString = finalString.replace(encode[0], encode[1]);
});
return finalString;
};
interface SearchObject {

Loading…
Cancel
Save