Make strings url safe (with no dependencies)
Make strings url-safe.
window.slugg) and AMD/CommonJS-flavoured module loaders
npm install slugg
var slug =//-> 'my-fantastic-blog-post'//-> 'today-i-found-5'//-> 'i-you'
If you want a separator other than '-', pass it in as the second argument:
//-> 'kevin spacey'
If you want to strip some characters rather than replace them with a separator, pass a regex as the last option that will match the chars you want to replace, eg:
Remember to use the
g flag if you want all the matches stripped (not just the first).