dodo / node-slug

slugifies even utf-8 chars!
MIT License
1.08k stars 92 forks source link

Feature suggestion: optionally add padding to mapped words #30

Open jaufgang opened 9 years ago

jaufgang commented 9 years ago

adding

if(opts.padMappedWords && char.length >1) char=' '+char+' '

after the chars have been mapped would allow

slug('m&m');  //=> 'mandm'
slug('i♥u');  //=> 'iloveu'

slug('m&m',{padMappedWords:true});  //=> 'm-and-m'
slug('i♥u',{padMappedWords:true}); //=> 'i-love-u'
dodo commented 9 years ago

how about:

slug('i♥u'.replace(/(\w+)/g, " $1 ")); //=> 'i-love-u'