Last active
July 23, 2023 21:24
-
-
Save abdumu/824b6852a320fbbc2d3759e1025fca7e to your computer and use it in GitHub Desktop.
Javascript function to generate a slug that `respect` Arabic.
This file contains 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\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