Created
November 10, 2017 03:40
-
-
Save loopiezlol/b1ab49094b5a25ed280ac41cd00a52be to your computer and use it in GitHub Desktop.
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
export default function (string) { | |
return ( | |
string | |
.toLowerCase() | |
.replace(/\s+/g, '-') | |
// eslint-disable-next-line | |
.replace(/[^\w\-]+/g, '') | |
// eslint-disable-next-line | |
.replace(/\-\-+/g, '-') | |
.replace(/^-+/, '') | |
.replace(/-+$/, '') | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment