
Make strings url-safe.
Vanilla javascript, no production dependencies.
Why not use slug? Or slugify? Well, I built this because I wanted a more transparent and powerfull implementation. If I wanted to preserve "/" and change "." to ":" I want to be able to do that, but still have the comfort of everything else being a default slugifier.
npm install larvitslugify
Examples
const slug = require('larvitslugify');
slug('i ♥ unicode');
slug('unicode ♥ is ☢');
slug('i ♥ unicode', '_');
slug.charmap['♥'] = 'freaking love'
slug('I ♥ UNICODE'));
slug('i <3 unicode');
Options
slug('string', [{options} || 'whitespaceReplaceChar']);
All options
slug('string', {
'whitespaceReplaceChar': '-',
'charmap': {'Å': 'A', 'Ö': 'O' ... },
'multiCharmap': = {'<3': 'love', '||': 'and'},
'removeMultipleWhitespace': = true,
'trim': = true,
'unidentifiedReplaceChar': = '',
'whitespaces': = [' ', '\t', '\xa0']
'save': = undefined
});