Remove case sensitive

This commit is contained in:
Peter Maquiran
2021-07-14 10:18:35 +01:00
parent 6176112001
commit db89f78de8
4 changed files with 32 additions and 9 deletions
+21
View File
@@ -0,0 +1,21 @@
// https://gist.github.com/marcelo-ribeiro/abd651b889e4a20e0bab558a05d38d77
const accentsMap = new Map([
["A", "Á|À|Ã|Â|Ä"],
["a", "á|à|ã|â|ä"],
["E", "É|È|Ê|Ë"],
["e", "é|è|ê|ë"],
["I", "Í|Ì|Î|Ï"],
["i", "í|ì|î|ï"],
["O", "Ó|Ò|Ô|Õ|Ö"],
["o", "ó|ò|ô|õ|ö"],
["U", "Ú|Ù|Û|Ü"],
["u", "ú|ù|û|ü"],
["C", "Ç"],
["c", "ç"],
["N", "Ñ"],
["n", "ñ"]
]);
const reducer = (acc, [key]) => acc.replace(new RegExp(accentsMap.get(key), "gi"), key);
export const slugify = (text) => [...accentsMap].reduce(reducer, text.toLowerCase());