1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
---
title: JavaScript naive slugify
date: 2021-04-03
updated_at: 2021-08-15
layout: post
lang: en
ref: javascript-naive-slugify
---
```javascript
const s = "Pézão: açaí, saci-pererê.";
const slugify = s =>
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));
```
|