diff options
author | EuAndreh <eu@euandre.org> | 2021-04-03 18:29:35 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-04-03 18:29:35 -0300 |
commit | 7d7aebde6e5ff1aeb221bc1b94adba4663880954 (patch) | |
tree | 18db631b2a947aaf805d06b08d80e9c100605d69 /_pastebins/2021-04-03-javascript-naive-slugify.md | |
parent | aux/workflow/public.sh: Mark as executable (diff) | |
download | euandre.org-7d7aebde6e5ff1aeb221bc1b94adba4663880954.tar.gz euandre.org-7d7aebde6e5ff1aeb221bc1b94adba4663880954.tar.xz |
/home/andreh/dev/libre/dotfiles/scripts/pastebin.sh: Auto-add _pastebins/2021-04-03-javascript-naive-slugify.md
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)); +``` |