mollusc
Make strings url-safe and replace unicode symbols with their name
- respecting RFC 3986
- Comprehensive tests
- No dependencies, except unicode data
- Coerces foreign symbols to their english equivalent
Install
npm install mollusc
Usage
const slug = //= i-love-unicode //= unicode-love-is-radioactive //= i_love_unicode slugcharmap'♥' = 'freaking love'//= i-freaking-love-unicode //= telephone-NUMBER
API
options
replacement
Replace spaces with value.
Type: string
Default: -
symbols
Replace unicode symbols with their name.
Type: boolean
Default:
- Node:
true
- Browser:
false
remove
Regex to remove characters.
Type: boolean
Default: null
lower
Convert result to lower case.
Type: boolean
Default: true
limit
Result should have no more than that many words.
Type: number
Default: null
charmap
Replace special characters.
Type: object
Default: slug.charmap
multicharmap
Replace strings with another string.
Type: object
Default: slug.multicharmap
Browser
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