Created
June 19, 2020 16:33
-
-
Save ahmadrosid/3bf8e16a9e6582328f323adddb665cdf to your computer and use it in GitHub Desktop.
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
export const slugify = (text?: string) => { | |
if (text == undefined) { | |
return ""; | |
} | |
return text | |
.toString() | |
.normalize("NFD") | |
.replace(/[\u0300-\u036f]/g, "") | |
.toLowerCase() | |
.trim() | |
.replace(/\s+/g, "-") | |
.replace(/[^\w\-]+/g, "") | |
.replace(/\-\-+/g, "-"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment