aboutsummaryrefslogtreecommitdiff
path: root/_pastebins/2021-04-03-javascript-naive-slugify.md
blob: 05251c771e788cf1f33e2779153eb1e7a37db6d9 (about) (plain) (blame)
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
---

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));
```