-
-
Save BSN4/1a0edbdfc76044395f9e614a162949e5 to your computer and use it in GitHub Desktop.
Javascript function to generate a slug that `respect` Arabic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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