Make strings url-safe and replace unicode symbols with their name
- respectingRFC 3986
- Comprehensive tests
- No dependencies, except unicode data
- Coerces foreign symbols to their english equivalent
npm install mollusc
constslug=require('mollusc')
slug('i ♥ unicode')
//= i-love-unicode
slug('unicode ♥ is ☢')
//= unicode-love-is-radioactive
slug('i ♥ unicode',{
replacement:'_'
})
//= i_love_unicode
slug.charmap['♥']='freaking love'
slug('I ♥ UNICODE')
//= i-freaking-love-unicode
slug('☏-NUMBER',{
lower:false
})
//= telephone-NUMBER
slug(input[,options])
Replace spaces with value.
Type:string
Default:-
Replace unicode symbols with their name.
Type:boolean
Default:
- Node:
true
- Browser:
false
Regex to remove characters.
Type:boolean
Default:null
Convert result to lower case.
Type:boolean
Default:true
Result should have no more than that many words.
Type:number
Default:null
Replace special characters.
Type:object
Default:slug.charmap
Replace strings with another string.
Type:object
Default:slug.multicharmap
When using browserify you might want to remove the symbols table from your bundle.
browserify slug.js --ignore unicode/category/So -s slug>slug-browser.js