aboutsummaryrefslogblamecommitdiff
path: root/_pastebins/2021-04-03-javascript-naive-slugify.md
blob: 05251c771e788cf1f33e2779153eb1e7a37db6d9 (plain) (tree)






































                                           
---

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