fix(autocomplete): avoid double escape of query params
This commit is contained in:
parent
67bbacbb05
commit
68fd34a732
1 changed files with 6 additions and 1 deletions
|
@ -26,7 +26,7 @@ type QueryKey = readonly [
|
|||
];
|
||||
|
||||
function buildURL(scope: string, term: string, extra?: string) {
|
||||
term = encodeURIComponent(term.replace(/\(|\)/g, ''));
|
||||
term = term.replace(/\(|\)/g, '');
|
||||
const params = new URLSearchParams();
|
||||
let path = `${api_geo_url}/${scope}`;
|
||||
|
||||
|
@ -73,6 +73,11 @@ const defaultQueryFn: QueryFunction<unknown, QueryKey> = async ({
|
|||
return matchSorter(await getPays(signal), term, { keys: ['label'] });
|
||||
}
|
||||
|
||||
// BAN will error with queries less then 3 chars long
|
||||
if (scope == 'adresse' && term.length < 3) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const url = buildURL(scope, term, extra);
|
||||
return httpRequest(url, { csrf: false, signal }).json();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue