Name: node-slug
Owner: Pressly Inc.
Description: slugifies even utf-8 chars!
Forked from: dodo/node-slug
Created: 2017-04-13 19:52:08.0
Updated: 2017-04-13 19:52:10.0
Pushed: 2017-04-13 20:53:48.0
Size: 80
Language: CoffeeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This is a Fork of node-slug with the unicode support removed - no longer have to handle issues related t unicode/category/So
slugifies every string, even when it contains unicode!
Make strings url-safe.
install slug
r install slug
slug = require('slug')
print = console.log.bind(console, '>')
t(slug('i ? unicode'))
i-love-unicode
t(slug('unicode ? is ?')) // yes!
unicode-love-is-radioactive
t(slug('i ? unicode', '_')) // If you prefer something else then `-` as seperator
i_love_unicode
.charmap['?'] = 'freaking love' // change default charmap or use option {charmap:{?}} as 2. argument
t(slug('I ? UNICODE'))
I-freaking-love-UNICODE
t(slug('?-Number', {lower: true})) // If you prefer lower case
telephone-number
t(slug('i <3 unicode'))
i-love-unicode
ptions is either object or replacement (sets options.replacement)
('string', [{options} || 'replacement']);
avascript
.defaults.mode ='pretty';
.defaults.modes['rfc3986'] = {
replacement: '-', // replace spaces with replacement
symbols: true, // replace unicode symbols or not
remove: null, // (optional) regex to remove characters
lower: true, // result in lower case
charmap: slug.charmap, // replace special characters
multicharmap: slug.multicharmap // replace multi-characters
.defaults.modes['pretty'] = {
replacement: '-',
symbols: true,
remove: /[.]/g,
lower: false,
charmap: slug.charmap,
multicharmap: slug.multicharmap
When using browserify you might want to remove the symbols table from your bundle by using --ignore
similar to this:
nerates a standalone slug browser bundle:
serify slug.js --ignore unicode/category/So -s slug > slug-browser.js