Skip to content

Instantly share code, notes, and snippets.

@BSN4
Forked from abdumu/slugify.js
Created September 24, 2018 14:11
Show Gist options
  • Save BSN4/1a0edbdfc76044395f9e614a162949e5 to your computer and use it in GitHub Desktop.
Save BSN4/1a0edbdfc76044395f9e614a162949e5 to your computer and use it in GitHub Desktop.
Javascript function to generate a slug that `respect` Arabic.
function slugify(text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^\w\u0600-\u06FF-]+/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '').replace(/-+$/, '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment