mirror of
https://github.com/catdevnull/transicion-desordenada-diablo
synced 2024-11-15 02:21:39 +00:00
frontend: permitir buscar ignorando mayusculas y tildes
This commit is contained in:
parent
0d9132a1f4
commit
ebf18dfbb8
1 changed files with 14 additions and 1 deletions
|
@ -20,11 +20,24 @@
|
|||
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 = "";
|
||||
function filterDatasets(datasets: Dataset[], query: string): Dataset[] {
|
||||
const q = processStringForSearch(query);
|
||||
return datasets.filter(
|
||||
(dataset) =>
|
||||
dataset.identifier.includes(query) || dataset.title.includes(query),
|
||||
processStringForSearch(dataset.identifier).includes(q) ||
|
||||
processStringForSearch(dataset.title).includes(q),
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue