Skip to content

Instantly share code, notes, and snippets.

@loopiezlol
Created November 10, 2017 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loopiezlol/b1ab49094b5a25ed280ac41cd00a52be to your computer and use it in GitHub Desktop.
Save loopiezlol/b1ab49094b5a25ed280ac41cd00a52be to your computer and use it in GitHub Desktop.
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