Skip to content

Instantly share code, notes, and snippets.

@abdumu
Last active July 23, 2023 21:24
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abdumu/824b6852a320fbbc2d3759e1025fca7e to your computer and use it in GitHub Desktop.
Save abdumu/824b6852a320fbbc2d3759e1025fca7e 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\u0621-\u064A0-9-]+/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '').replace(/-+$/, '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment