mol

mollusc

slugifies even utf-8 chars!

Showing:

Popularity

Downloads/wk

190

GitHub Stars

20

Maintenance

Last Commit

4yrs ago

Contributors

22

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

mollusc Build Status NPM version Coverage Status js-standard-style

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 = 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

API

slug(input[, options])

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial