diff options
Diffstat (limited to '')
-rw-r--r-- | _pastebins/2021-04-03-javascript-naive-slugify.md | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/_pastebins/2021-04-03-javascript-naive-slugify.md b/_pastebins/2021-04-03-javascript-naive-slugify.md new file mode 100644 index 0000000..05251c7 --- /dev/null +++ b/_pastebins/2021-04-03-javascript-naive-slugify.md @@ -0,0 +1,39 @@ +--- + +title: JavaScript naive slugify + +date: 2021-04-03 + +layout: post + +lang: en + +ref: javascript-naive-slugify + +--- + +```javascript +const s = "Pézão: açaí, saci-pererê."; + +function slugify(s) { + return s + .toLowerCase() + .replaceAll(":", "") + .replaceAll(".", "") + .replaceAll(",", "") + .replaceAll("-", "") + .replaceAll("á", "a") + .replaceAll("ã", "a") + .replaceAll("à", "a") + .replaceAll("é", "e") + .replaceAll("ê", "e") + .replaceAll("í", "i") + .replaceAll("ó", "o") + .replaceAll("ô", "o") + .replaceAll("ú", "u") + .replaceAll("ü", "u") + .replaceAll("ç", "c"); +} + +console.log(slugify(s)); +``` |