slugger
Dead simple slugification for node and browser.
What it does:
Converts any string into a url friendly version:
slugger('Hello yOu CRAZY Swede!');
slugger('Hello yOu CRAZY Swede!', {maintainCase: true});
slugger('Hello yOu CRAZY Swede!', {replacement: '_'});
slugger('Hello yOu CRAZY Swede!', {smartTrim: 9});
slugger('Hello yOu CRAZY Swede!', {alsoAllow: "!&"});
slugger('boo%20boo')
slugger('boo%20boo', {decode: false})
That's all there is to it!
Installing
npm install slugger
Or just grab the slugger.js file and drop it into your project.
It also plays nicely with: https://github.com/henrikjoreteg/clientmodules
Because I wanted something simpler that didn't try to do anything with special characters or unicode and I wanted something that worked well in the browser or node.
Tests?
Just run npm test
Changelog
- 0.1.0 - Adding option to allow other characters
Dig it?
Then you should probably follow @HenrikJoreteg on twitter.
License
MIT