slugifies every string, even when it contains unicode!
Make strings url-safe.
- respecting RFC 3986
- Comprehensive tests
- No dependencies (except the unicode table)
- Not in coffee-script (except the tests lol)
- Coerces foreign symbols to their english equivalent
- Works in browser (window.slug) and AMD/CommonJS-flavoured module loaders (except the unicode symbols unless you use browserify but who wants to download a ~2mb js file, right?)
npm install slug
example
var slug = require('slug')
var print = console.log.bind(console, '>')
print(slug('i ♥ unicode'))
print(slug('unicode ♥ is ☢'))
print(slug('i ♥ unicode', '_'))
slug.charmap['♥'] = 'freaking love'
print(slug('I ♥ UNICODE').toLowerCase())
options
slug('string', [{options} || 'replacement']);
slug.defaults = {
replacement: '-',
symbols: true,
charmap: slug.charmap,
};