frontend: permitir buscar ignorando mayusculas y tildes

This commit is contained in:
Cat /dev/Nulo 2023-12-08 19:29:44 -03:00
parent 0d9132a1f4
commit ebf18dfbb8

View file

@ -20,11 +20,24 @@
return url; return url;
} }
function processStringForSearch(str: string): string {
return str
.toLowerCase()
.replaceAll("á", "a")
.replaceAll("é", "e")
.replaceAll("í", "i")
.replaceAll("ó", "o")
.replaceAll("ú", "u")
.replaceAll("ñ", "n");
}
let query: string = ""; let query: string = "";
function filterDatasets(datasets: Dataset[], query: string): Dataset[] { function filterDatasets(datasets: Dataset[], query: string): Dataset[] {
const q = processStringForSearch(query);
return datasets.filter( return datasets.filter(
(dataset) => (dataset) =>
dataset.identifier.includes(query) || dataset.title.includes(query), processStringForSearch(dataset.identifier).includes(q) ||
processStringForSearch(dataset.title).includes(q),
); );
} }
</script> </script>