Giter Club home page Giter Club logo

node-slug's Introduction

slugifies every string, even when it contains unicode!

Make strings url-safe.

  • respecting RFC 3986
  • Comprehensive tests
  • No dependencies (except the unicode table)
  • Not in coffee-script (except the tests lol)
  • Coerces foreign symbols to their english equivalent
  • Works in browser (window.slug) and AMD/CommonJS-flavoured module loaders (except the unicode symbols unless you use browserify but who wants to download a ~2mb js file, right?)
npm install slug
bower install slug

example

var slug = require('slug')
var print = console.log.bind(console, '>')

print(slug('i ♥ unicode'))
// > i-love-unicode

print(slug('unicode ♥ is ☢')) // yes!
// > unicode-love-is-radioactive

print(slug('i ♥ unicode', '_')) // If you prefer something else then `-` as seperator
// > i_love_unicode

slug.charmap['♥'] = 'freaking love' // change default charmap or use option {charmap:{…}} as 2. argument
print(slug('I ♥ UNICODE'))
// > I-freaking-love-UNICODE

print(slug('☏-Number', {lower: true})) // If you prefer lower case
// > telephone-number

print(slug('i <3 unicode'))
// > i-love-unicode

options

// options is either object or replacement (sets options.replacement)
slug('string', [{options} || 'replacement']);
slug.defaults.mode ='pretty';
slug.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
};
slug.defaults.modes['pretty'] = {
    replacement: '-',
    symbols: true,
    remove: /[.]/g,
    lower: false,
    charmap: slug.charmap,
    multicharmap: slug.multicharmap
};

browser

When using browserify you might want to remove the symbols table from your bundle by using --ignore similar to this:

# generates a standalone slug browser bundle:
browserify slug.js --ignore unicode/category/So -s slug > slug-browser.js

Build Status

Bitdeli Badge

node-slug's People

Contributors

bitdeli-chef avatar dodo avatar dominhhai avatar dominykas avatar jaketrent avatar linusu avatar mitica avatar niftylettuce avatar prozacgod avatar srtech avatar vesln avatar wyoumans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-slug's Issues

Not properly slugifying

"It's your journey ... we guide you through."

converts to

It\'s-your-journey-...-we-guide-you-through.

which is invalid

Slug does not remove Unicode Characters

Tried to make it so slug removes some special characters, but it seems to be broken.

var slugName = slug(name, {lower: true, remove: /®/g})

is not working

var slugName = slug(name, {lower: true, remove: new RegExp('\u00AE', 'g')})

didn't work either.

thanks!

<3 is a little aggressive for a default

I like that <3 is replaced with love. It's cute. But what if I want to slug a math expression: 2<3? How does it know when I want 'less than' rather than 'love'?

<3 might be better as an example of adding a replacement instead of being default.

Thoughts?

Possibly incompatible with jspm frontend package manager?

After doing a jspm install npm:slug I get an error when trying to use your library.

It looks like its trying to interact with a file So.js related to the unicode dependency. Perhaps it doesn't recognise the jspm SystemJS environment properly? Maybe?

Error while compiling (both with `$ coffee` and `$ cake build`)

nifty@nifty ~/Public/node-slug $ coffee -c src/slug.coffee
SyntaxError: In src/slug.coffee, multiple object literal properties named "'ç'"
    at SyntaxError (unknown source)
    at Obj.compileNode (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:1187:19)
    at Obj.compile (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:46:21)
    at Value.compileNode (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:701:24)
    at Value.compile (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:46:21)
    at Assign.compileNode (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:1554:24)
    at Assign.compile (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:46:21)
    at Block.compileNode (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:307:23)
    at Block.compileWithDeclarations (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:391:19)
    at Block.compileRoot (/home/nifty/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:364:19)

Unicode dependency postinstall is breaking on elasticbeanstalk at the moment

Hi!

I'm not going to be super helpful on this one, but on AWS Elasticbeanstalk I get the following error when installing Slug.

67126 verbose stack Error: [email protected] postinstall: `node install.js`
67126 verbose stack Exit status 1
67126 verbose stack     at EventEmitter.<anonymous> (/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
67126 verbose stack     at emitTwo (events.js:106:13)
67126 verbose stack     at EventEmitter.emit (events.js:191:7)
67126 verbose stack     at ChildProcess.<anonymous> (/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/lib/node_modules/npm/lib/utils/spawn.js:40:14)
67126 verbose stack     at emitTwo (events.js:106:13)
67126 verbose stack     at ChildProcess.emit (events.js:191:7)
67126 verbose stack     at maybeClose (internal/child_process.js:877:16)
67126 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
67127 verbose pkgid [email protected]
67128 verbose cwd /tmp/deployment/application
67129 error Linux 4.4.35-33.55.amzn1.x86_64
67130 error argv "/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/npm" "--production" "install"
67131 error node v6.9.1
67132 error npm  v3.10.8
67133 error code ELIFECYCLE
67134 error [email protected] postinstall: `node install.js`

Worked around by forking and replacing the [email protected] dependency.
Replaced in my package.json the slug depency with "slug": "git+https://[email protected]/180-g/node-slug",

See https://github.com/180-g/node-slug

No indication whatsoever of what the problem is. Noticed that another fork has been done 3 days ago. Decided to fork too, might be an indicator something is wrong with the package.

Arabic characters

Hey guys,

It doesn't work for some language:

> var t = "تحية الاسلام مدخل لدعوة غير المسلمين من الوافدين";
> slug(t);
''

Thanks,
Philmod

Windows support?

Russ Thomas wrote me an email with the following log. He was trying to install vesln/word (slug is dep) on windows. I guess the preinstall script didn't work quite well. Any idea how we can make that working on windows?

info it worked if it ends with ok
verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
verbose cli   'install',
verbose cli   'word' ]
info using [email protected]
info using [email protected]
verbose config file C:\Users\russ\.npmrc
verbose config file C:\Program Files\nodejs\etc\npmrc
verbose config file C:\Program Files\nodejs\node_modules\npm\npmrc
verbose mkdir done: C:\Program Files\iisnode 755
verbose into C:\Program Files\iisnode [ 'word' ]
verbose cache add word
verbose cache add [ 'word', null ]
silly cache add: name, spec, args [ undefined, 'word', [ 'word', null ] ]
verbose parsed url { pathname: 'word', path: 'word', href: 'word' }
verbose addNamed [ 'word', '' ]
verbose addNamed [ null, '' ]
silly name, range, hasData [ 'word', '', false ]
verbose raw, before any munging word
verbose url resolving [ 'https://registry.npmjs.org/', './word' ]
verbose url resolved https://registry.npmjs.org/word
verbose etag "2RBCM3PVVFXSJF1YYRKF97ORN"
http GET https://registry.npmjs.org/word
http 304 https://registry.npmjs.org/word
silly get cb [ 304,
silly get cb   { server: 'CouchDB/1.1.0 (Erlang OTP/R14B04)',
silly get cb     etag: '"2RBCM3PVVFXSJF1YYRKF97ORN"',
silly get cb     date: 'Thu, 12 Jan 2012 22:05:44 GMT',
silly get cb     'content-length': '0' } ]
verbose etag word from cache
verbose mkdir done: C:\Users\russ\AppData\Roaming\npm-cache\word 755
silly name, range, hasData 2 [ 'word', '', true ]
silly versions [ 'word', [ '0.0.1', '0.1.0', '0.2.1', '0.2.2' ] ]
verbose bin dist [ '0.6-ares1.7.5-DEV-evundefined-openssl0.9.8r-v83.6.6.14-win32-ia32-6.0.6002',
verbose bin dist   { shasum: 'd4896ea9b21d796fee27ea1fd7277438577bd136',
verbose bin dist     tarball: 'http://registry.npmjs.org/word/-/word-0.2.2.tgz' } ]
verbose caching C:\Users\russ\AppData\Roaming\npm-cache\word\0.2.2\package\package.json
verbose loadDefaults [email protected]
silly resolved [ { name: 'word',
silly resolved     version: '0.2.2',
silly resolved     description: 'Contains functions that assist in working with strings.',
silly resolved     keywords: [ 'string helper', 'text helper', 'string', 'text' ],
silly resolved     author: { name: 'Veselin Todorov', email: '[email protected]' },
silly resolved     dependencies: 
silly resolved      { package: '1.0.0',
silly resolved        lingo: '0.0.4',
silly resolved        super: '0.0.1',
silly resolved        slug: '0.1.1' },
silly resolved     devDependencies: { mocha: '0.3.3', should: '0.3.2', 'coffee-script': '1.2.0' },
silly resolved     repository: { type: 'git', url: 'git://github.com/vesln/word.git' },
silly resolved     homepage: 'http://github.com/vesln/word',
silly resolved     scripts: 
silly resolved      { test: 'cake test',
silly resolved        prepublish: 'cake build',
silly resolved        postpublish: 'cake clean' },
silly resolved     main: './lib/word',
silly resolved     engines: { node: '>= 0.6.0 < 0.7.0' },
silly resolved     _id: '[email protected]',
silly resolved     _engineSupported: true,
silly resolved     _npmVersion: '1.1.0-beta-4',
silly resolved     _nodeVersion: 'v0.6.6',
silly resolved     _defaultsLoaded: true } ]
info into C:\Program Files\iisnode [email protected]
info installOne [email protected]
info unbuild C:\Program Files\iisnode\node_modules\word
verbose from cache C:\Users\russ\AppData\Roaming\npm-cache\word\0.2.2\package\package.json
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Program Files\iisnode\node_modules\___word.npm'
verbose mkdir done: C:\Program Files\iisnode\node_modules\___word.npm 755
verbose unpack_ uid, gid [ undefined, undefined ]
verbose unpackTarget C:\Program Files\iisnode\node_modules\word
silly gunzTarPerm modes [ '755', '644' ]
silly afterUntar undefined
verbose gunzed C:\Program Files\iisnode\node_modules\___word.npm\package
verbose rm'ed C:\Program Files\iisnode\node_modules\word
verbose renamed [ 'C:\\Program Files\\iisnode\\node_modules\\___word.npm\\package',
verbose renamed   'C:\\Program Files\\iisnode\\node_modules\\word' ]
verbose caching C:\Program Files\iisnode\node_modules\word\package.json
verbose loadDefaults [email protected]
info preinstall [email protected]
verbose from cache C:\Program Files\iisnode\node_modules\word\package.json
verbose into C:\Program Files\iisnode\node_modules\word [ '[email protected]', '[email protected]', '[email protected]', '[email protected]' ]
verbose cache add [email protected]
verbose cache add [ '[email protected]', null ]
silly cache add: name, spec, args [ undefined, '[email protected]', [ '[email protected]', null ] ]
verbose parsed url { pathname: '[email protected]',
verbose parsed url   path: '[email protected]',
verbose parsed url   href: '[email protected]' }
silly cache add: name, spec, args [ 'package', '1.0.0', [ 'package', '1.0.0' ] ]
verbose parsed url { pathname: '1.0.0', path: '1.0.0', href: '1.0.0' }
verbose addNamed [ 'package', '1.0.0' ]
verbose addNamed [ '1.0.0', '1.0.0' ]
verbose raw, before any munging package/1.0.0
verbose url resolving [ 'https://registry.npmjs.org/', './package/1.0.0' ]
verbose url resolved https://registry.npmjs.org/package/1.0.0
verbose etag "9CZH70CSG6R3ZKIQ35CVRHQ9Z"
http GET https://registry.npmjs.org/package/1.0.0
verbose cache add [email protected]
verbose cache add [ '[email protected]', null ]
silly cache add: name, spec, args [ undefined, '[email protected]', [ '[email protected]', null ] ]
verbose parsed url { pathname: '[email protected]',
verbose parsed url   path: '[email protected]',
verbose parsed url   href: '[email protected]' }
silly cache add: name, spec, args [ 'lingo', '0.0.4', [ 'lingo', '0.0.4' ] ]
verbose parsed url { pathname: '0.0.4', path: '0.0.4', href: '0.0.4' }
verbose addNamed [ 'lingo', '0.0.4' ]
verbose addNamed [ '0.0.4', '0.0.4' ]
verbose cache add [email protected]
verbose cache add [ '[email protected]', null ]
silly cache add: name, spec, args [ undefined, '[email protected]', [ '[email protected]', null ] ]
verbose parsed url { pathname: '[email protected]',
verbose parsed url   path: '[email protected]',
verbose parsed url   href: '[email protected]' }
silly cache add: name, spec, args [ 'super', '0.0.1', [ 'super', '0.0.1' ] ]
verbose parsed url { pathname: '0.0.1', path: '0.0.1', href: '0.0.1' }
verbose addNamed [ 'super', '0.0.1' ]
verbose addNamed [ '0.0.1', '0.0.1' ]
verbose cache add [email protected]
verbose cache add [ '[email protected]', null ]
silly cache add: name, spec, args [ undefined, '[email protected]', [ '[email protected]', null ] ]
verbose parsed url { pathname: '[email protected]',
verbose parsed url   path: '[email protected]',
verbose parsed url   href: '[email protected]' }
silly cache add: name, spec, args [ 'slug', '0.1.1', [ 'slug', '0.1.1' ] ]
verbose parsed url { pathname: '0.1.1', path: '0.1.1', href: '0.1.1' }
verbose addNamed [ 'slug', '0.1.1' ]
verbose addNamed [ '0.1.1', '0.1.1' ]
verbose raw, before any munging lingo/0.0.4
verbose url resolving [ 'https://registry.npmjs.org/', './lingo/0.0.4' ]
verbose url resolved https://registry.npmjs.org/lingo/0.0.4
verbose etag "7RAROGA1U9P47PYXM3OP3Q0PQ"
http GET https://registry.npmjs.org/lingo/0.0.4
verbose raw, before any munging slug/0.1.1
verbose url resolving [ 'https://registry.npmjs.org/', './slug/0.1.1' ]
verbose url resolved https://registry.npmjs.org/slug/0.1.1
verbose etag "1LZE16YW790CU4OF7IIFE0DA9"
http GET https://registry.npmjs.org/slug/0.1.1
verbose raw, before any munging super/0.0.1
verbose url resolving [ 'https://registry.npmjs.org/', './super/0.0.1' ]
verbose url resolved https://registry.npmjs.org/super/0.0.1
verbose etag "CVDX0409VMZ35K7247AOLUG7F"
http GET https://registry.npmjs.org/super/0.0.1
http 304 https://registry.npmjs.org/lingo/0.0.4
silly get cb [ 304,
silly get cb   { server: 'CouchDB/1.1.0 (Erlang OTP/R14B04)',
silly get cb     etag: '"7RAROGA1U9P47PYXM3OP3Q0PQ"',
silly get cb     date: 'Thu, 12 Jan 2012 22:05:46 GMT',
silly get cb     'content-length': '0' } ]
verbose etag lingo/0.0.4 from cache
verbose mkdir done: C:\Users\russ\AppData\Roaming\npm-cache\lingo\0.0.4 755
verbose bin dist [ '0.6-ares1.7.5-DEV-evundefined-openssl0.9.8r-v83.6.6.14-win32-ia32-6.0.6002',
verbose bin dist   { tarball: 'http://registry.npmjs.org/lingo/-/lingo-0.0.4.tgz' } ]
verbose caching C:\Users\russ\AppData\Roaming\npm-cache\lingo\0.0.4\package\package.json
verbose loadDefaults [email protected]
http 304 https://registry.npmjs.org/slug/0.1.1
silly get cb [ 304,
silly get cb   { server: 'CouchDB/1.1.0 (Erlang OTP/R14B04)',
silly get cb     etag: '"1LZE16YW790CU4OF7IIFE0DA9"',
silly get cb     date: 'Thu, 12 Jan 2012 22:05:46 GMT',
silly get cb     'content-length': '0' } ]
verbose etag slug/0.1.1 from cache
verbose mkdir done: C:\Users\russ\AppData\Roaming\npm-cache\slug\0.1.1 755
verbose bin dist [ '0.6-ares1.7.5-DEV-evundefined-openssl0.9.8r-v83.6.6.14-win32-ia32-6.0.6002',
verbose bin dist   { shasum: '6dd4ddadfb937fc0b9a7cf5e97307ee080547fed',
verbose bin dist     tarball: 'http://registry.npmjs.org/slug/-/slug-0.1.1.tgz' } ]
verbose has wscript [ undefined,
verbose has wscript   { file: 'C:\\Users\\russ\\AppData\\Roaming\\npm-cache\\slug\\0.1.1\\package\\package.json',
verbose has wscript     contributors: false,
verbose has wscript     serverjs: false,
verbose has wscript     wscript: true } ]
verbose caching C:\Users\russ\AppData\Roaming\npm-cache\slug\0.1.1\package\package.json
verbose loadDefaults [email protected]
http 304 https://registry.npmjs.org/super/0.0.1
silly get cb [ 304,
silly get cb   { server: 'CouchDB/1.1.0 (Erlang OTP/R14B04)',
silly get cb     etag: '"CVDX0409VMZ35K7247AOLUG7F"',
silly get cb     date: 'Thu, 12 Jan 2012 22:05:46 GMT',
silly get cb     'content-length': '0' } ]
verbose etag super/0.0.1 from cache
verbose mkdir done: C:\Users\russ\AppData\Roaming\npm-cache\super\0.0.1 755
verbose bin dist [ '0.6-ares1.7.5-DEV-evundefined-openssl0.9.8r-v83.6.6.14-win32-ia32-6.0.6002',
verbose bin dist   { shasum: '81537ca068aa3953ff488ca4236454a61ce57a80',
verbose bin dist     tarball: 'http://registry.npmjs.org/super/-/super-0.0.1.tgz' } ]
verbose caching C:\Users\russ\AppData\Roaming\npm-cache\super\0.0.1\package\package.json
verbose loadDefaults [email protected]
http 304 https://registry.npmjs.org/package/1.0.0
silly get cb [ 304,
silly get cb   { server: 'CouchDB/1.1.0 (Erlang OTP/R14B04)',
silly get cb     etag: '"9CZH70CSG6R3ZKIQ35CVRHQ9Z"',
silly get cb     date: 'Thu, 12 Jan 2012 22:05:46 GMT',
silly get cb     'content-length': '0' } ]
verbose etag package/1.0.0 from cache
verbose mkdir done: C:\Users\russ\AppData\Roaming\npm-cache\package\1.0.0 755
verbose bin dist [ '0.6-ares1.7.5-DEV-evundefined-openssl0.9.8r-v83.6.6.14-win32-ia32-6.0.6002',
verbose bin dist   { shasum: 'f54087d4faf4df862a25b98e79fe51246f717999',
verbose bin dist     tarball: 'http://registry.npmjs.org/package/-/package-1.0.0.tgz' } ]
verbose caching C:\Users\russ\AppData\Roaming\npm-cache\package\1.0.0\package\package.json
verbose loadDefaults [email protected]
silly resolved [ { name: 'lingo',
silly resolved     description: 'linguistics module sporting inflection and more',
silly resolved     version: '0.0.4',
silly resolved     author: { name: 'TJ Holowaychuk', email: '[email protected]' },
silly resolved     keywords: [ 'language', 'linguistics', 'inflection' ],
silly resolved     main: './index.js',
silly resolved     engines: { node: '>= 0.2.0' },
silly resolved     _id: '[email protected]',
silly resolved     dependencies: {},
silly resolved     devDependencies: {},
silly resolved     _engineSupported: true,
silly resolved     _npmVersion: '1.1.0-beta-4',
silly resolved     _nodeVersion: 'v0.6.6',
silly resolved     _defaultsLoaded: true },
silly resolved   { name: 'slug',
silly resolved     description: 'slugifies even utf-8 chars!',
silly resolved     version: '0.1.1',
silly resolved     homepage: 'https://github.com/dodo/node-slug',
silly resolved     author: { name: 'dodo', url: 'https://github.com/dodo' },
silly resolved     repository: { type: 'git', url: 'git://github.com/dodo/node-slug.git' },
silly resolved     main: 'slug.js',
silly resolved     engines: { node: '>= 0.4.x' },
silly resolved     keywords: [ 'slugify', 'slug', 'string', 'utf8', 'utf-8', 'unicode', 'url' ],
silly resolved     scripts: 
silly resolved      { preinstall: '#preinstall DO NOTHING',
silly resolved        install: 'node-waf configure build',
silly resolved        update: 'node-waf build' },
silly resolved     dependencies: { unicode: '>= 0.2.1', 'coffee-script': '>= 1.1.2' },
silly resolved     _id: '[email protected]',
silly resolved     devDependencies: {},
silly resolved     _engineSupported: true,
silly resolved     _npmVersion: '1.1.0-beta-4',
silly resolved     _nodeVersion: 'v0.6.6',
silly resolved     _defaultsLoaded: true },
silly resolved   { name: 'super',
silly resolved     version: '0.0.1',
silly resolved     description: 'Extend everything.',
silly resolved     keywords: [ 'extend', 'inherits', 'super' ],
silly resolved     author: { name: 'Veselin Todorov', email: '[email protected]' },
silly resolved     dependencies: { package: '1.0.0' },
silly resolved     devDependencies: { mocha: '0.3.3', should: '0.3.2' },
silly resolved     repository: { type: 'git', url: 'git://github.com/vesln/super.git' },
silly resolved     homepage: 'http://github.com/vesln/super',
silly resolved     scripts: { test: 'make test' },
silly resolved     main: './lib/super',
silly resolved     engines: { node: '>= 0.6.0 < 0.7.0' },
silly resolved     _id: '[email protected]',
silly resolved     _engineSupported: true,
silly resolved     _npmVersion: '1.1.0-beta-4',
silly resolved     _nodeVersion: 'v0.6.6',
silly resolved     _defaultsLoaded: true },
silly resolved   { name: 'package',
silly resolved     version: '1.0.0',
silly resolved     description: 'Easy package.json exports.',
silly resolved     keywords: [ 'package.json' ],
silly resolved     author: { name: 'Veselin Todorov', email: '[email protected]' },
silly resolved     devDependencies: { mocha: '0.3.3', should: '0.3.2' },
silly resolved     repository: { type: 'git', url: 'git://github.com/vesln/package.git' },
silly resolved     homepage: 'http://github.com/vesln/package',
silly resolved     scripts: { test: 'make test' },
silly resolved     main: './lib/package',
silly resolved     engines: { node: '>= 0.6.0 < 0.7.0' },
silly resolved     _id: '[email protected]',
silly resolved     dependencies: {},
silly resolved     _engineSupported: true,
silly resolved     _npmVersion: '1.1.0-beta-4',
silly resolved     _nodeVersion: 'v0.6.6',
silly resolved     _defaultsLoaded: true } ]
info into C:\Program Files\iisnode\node_modules\word [email protected]
info into C:\Program Files\iisnode\node_modules\word [email protected]
info into C:\Program Files\iisnode\node_modules\word [email protected]
info into C:\Program Files\iisnode\node_modules\word [email protected]
info installOne [email protected]
info installOne [email protected]
info installOne [email protected]
info installOne [email protected]
info unbuild C:\Program Files\iisnode\node_modules\word\node_modules\slug
info unbuild C:\Program Files\iisnode\node_modules\word\node_modules\lingo
info unbuild C:\Program Files\iisnode\node_modules\word\node_modules\super
info unbuild C:\Program Files\iisnode\node_modules\word\node_modules\package
verbose from cache C:\Users\russ\AppData\Roaming\npm-cache\slug\0.1.1\package\package.json
verbose from cache C:\Users\russ\AppData\Roaming\npm-cache\super\0.0.1\package\package.json
verbose from cache C:\Users\russ\AppData\Roaming\npm-cache\lingo\0.0.4\package\package.json
verbose from cache C:\Users\russ\AppData\Roaming\npm-cache\package\1.0.0\package\package.json
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Program Files\iisnode\node_modules\word\node_modules'
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Program Files\iisnode\node_modules\word\node_modules'
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Program Files\iisnode\node_modules\word\node_modules'
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Program Files\iisnode\node_modules\word\node_modules\___lingo.npm'
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Program Files\iisnode\node_modules\word\node_modules\___package.npm'
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Program Files\iisnode\node_modules\word\node_modules\___slug.npm'
verbose mkdir done: C:\Program Files\iisnode\node_modules\word\node_modules\___package.npm 755
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Program Files\iisnode\node_modules\word\node_modules\___super.npm'
verbose mkdir done: C:\Program Files\iisnode\node_modules\word\node_modules\___slug.npm 755
verbose mkdir done: C:\Program Files\iisnode\node_modules\word\node_modules\___lingo.npm 755
verbose unpack_ uid, gid [ undefined, undefined ]
verbose unpackTarget C:\Program Files\iisnode\node_modules\word\node_modules\package
silly gunzTarPerm modes [ '755', '644' ]
verbose unpack_ uid, gid [ undefined, undefined ]
verbose unpackTarget C:\Program Files\iisnode\node_modules\word\node_modules\lingo
silly gunzTarPerm modes [ '755', '644' ]
verbose unpack_ uid, gid [ undefined, undefined ]
verbose unpackTarget C:\Program Files\iisnode\node_modules\word\node_modules\slug
silly gunzTarPerm modes [ '755', '644' ]
verbose mkdir done: C:\Program Files\iisnode\node_modules\word\node_modules\___super.npm 755
verbose unpack_ uid, gid [ undefined, undefined ]
verbose unpackTarget C:\Program Files\iisnode\node_modules\word\node_modules\super
silly gunzTarPerm modes [ '755', '644' ]
silly afterUntar undefined
verbose gunzed C:\Program Files\iisnode\node_modules\word\node_modules\___slug.npm\package
verbose rm'ed C:\Program Files\iisnode\node_modules\word\node_modules\slug
verbose renamed [ 'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules\\___slug.npm\\package',
verbose renamed   'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules\\slug' ]
verbose has wscript [ undefined,
verbose has wscript   { file: 'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules\\slug\\package.json',
verbose has wscript     contributors: false,
verbose has wscript     serverjs: false,
verbose has wscript     wscript: true } ]
verbose caching C:\Program Files\iisnode\node_modules\word\node_modules\slug\package.json
verbose loadDefaults [email protected]
silly afterUntar undefined
verbose gunzed C:\Program Files\iisnode\node_modules\word\node_modules\___super.npm\package
verbose rm'ed C:\Program Files\iisnode\node_modules\word\node_modules\super
info preinstall [email protected]
verbose unsafe-perm in lifecycle true
silly exec cmd "/c" "#preinstall DO NOTHING"
silly spawning [ 'cmd',
silly spawning   [ '/c', '#preinstall DO NOTHING' ],
silly spawning   'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules\\slug' ]
verbose renamed [ 'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules\\___super.npm\\package',
verbose renamed   'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules\\super' ]
verbose caching C:\Program Files\iisnode\node_modules\word\node_modules\super\package.json
verbose loadDefaults [email protected]
info preinstall [email protected]
verbose from cache C:\Program Files\iisnode\node_modules\word\node_modules\super\package.json
verbose into C:\Program Files\iisnode\node_modules\word\node_modules\super []
silly resolved []
verbose about to build C:\Program Files\iisnode\node_modules\word\node_modules\super
info build C:\Program Files\iisnode\node_modules\word\node_modules\super
verbose from cache C:\Program Files\iisnode\node_modules\word\node_modules\super\package.json
verbose linkStuff [ false,
verbose linkStuff   false,
verbose linkStuff   false,
verbose linkStuff   'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules' ]
info linkStuff [email protected]
verbose linkBins [email protected]
verbose linkMans [email protected]
verbose rebuildBundles [email protected]
info install [email protected]
info postinstall [email protected]
verbose installOne cb [email protected]
info [email protected] Failed to exec preinstall script
ERR! error installing [email protected]
info unbuild C:\Program Files\iisnode\node_modules\word\node_modules\slug
verbose from cache C:\Program Files\iisnode\node_modules\word\node_modules\slug\package.json
info preuninstall [email protected]
info uninstall [email protected]
verbose unbuild [email protected] [ false,
verbose unbuild [email protected]   'C:\\Program Files\\iisnode\\node_modules',
verbose unbuild [email protected]   'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules' ]
info postuninstall [email protected]
silly afterUntar undefined
verbose gunzed C:\Program Files\iisnode\node_modules\word\node_modules\___package.npm\package
verbose rm'ed C:\Program Files\iisnode\node_modules\word\node_modules\package
verbose renamed [ 'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules\\___package.npm\\package',
verbose renamed   'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules\\package' ]
verbose caching C:\Program Files\iisnode\node_modules\word\node_modules\package\package.json
verbose loadDefaults [email protected]
verbose installOne cb [email protected]
verbose about to build C:\Program Files\iisnode\node_modules\word
ERR! error installing [email protected]
info unbuild C:\Program Files\iisnode\node_modules\word
verbose from cache C:\Program Files\iisnode\node_modules\word\package.json
info preuninstall [email protected]
info preinstall [email protected]
info uninstall [email protected]
verbose unbuild [email protected] [ true,
verbose unbuild [email protected]   'C:\\Program Files\\iisnode\\node_modules',
verbose unbuild [email protected]   'C:\\Program Files\\iisnode\\node_modules' ]
info postuninstall [email protected]
verbose caching C:\Program Files\iisnode\node_modules\word\node_modules\package\package.json
verbose loadDefaults [email protected]
verbose into C:\Program Files\iisnode\node_modules\word\node_modules\package []
silly resolved []
verbose about to build C:\Program Files\iisnode\node_modules\word\node_modules\package
info build C:\Program Files\iisnode\node_modules\word\node_modules\package
verbose from cache C:\Program Files\iisnode\node_modules\word\node_modules\package\package.json
verbose linkStuff [ false,
verbose linkStuff   false,
verbose linkStuff   false,
verbose linkStuff   'C:\\Program Files\\iisnode\\node_modules\\word\\node_modules' ]
info linkStuff [email protected]
verbose linkBins [email protected]
verbose linkMans [email protected]
verbose rebuildBundles [email protected]
info install [email protected]
info postinstall [email protected]
verbose installOne cb [email protected]
ERR! error rolling back [email protected] Error: UNKNOWN, unknown error 'C:\Program Files\iisnode\node_modules\word\node_modules\___lingo.npm\package'
verbose installOne cb [email protected]
ERR! [email protected] preinstall: `#preinstall DO NOTHING`
ERR! `cmd "/c" "#preinstall DO NOTHING"` failed with 1
ERR! 
ERR! Failed at the [email protected] preinstall script.
ERR! This is most likely a problem with the slug package,
ERR! not with npm itself.
ERR! Tell the author that this fails on your system:
ERR!     #preinstall DO NOTHING
ERR! You can get their info via:
ERR!     npm owner ls slug
ERR! There is likely additional logging output above.
ERR! 
ERR! System Windows_NT 6.0.6002
ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "word"
ERR! cwd C:\Program Files\iisnode
ERR! node -v v0.6.6
ERR! npm -v 1.1.0-beta-4
ERR! code ELIFECYCLE
ERR! message [email protected] preinstall: `#preinstall DO NOTHING`
ERR! message `cmd "/c" "#preinstall DO NOTHING"` failed with 1
verbose exit [ 1, true ]

Tests

I'll be glad to write some tests with mocha and should, if that's priority for the project. Thanks.

Unable to turn off symbols replacement

Hi,

I tried with custom options object and the usage looks like this:

const slugifiedValue = slug(value, { lower: true, symbols: false })

The library still convetes symbols like < or <3 to their representations ('less', 'love'). Options dict isn't completely ignored, because lower option is fine. The problem is with symbols option - it's not taken into consideration by the current implementation.

Environment:
React/Webpack project executed in Chrome browser

Slugs for Russian words?

Hi,

If I try this:

slug("Ревущий фьорд")
'Revushij-ford'

I was hoping for 'ревущии-фьорд' (ie what the WoW api has :) ) - does slug do a letter by letter translation or something?

Thanks,
Chris

Cannot find module 'unicode/category/So'

Cannot find module 'unicode/category/So'

it craps out on the const slug = require('slug') statement. it works fine on mac. but debian and ubuntu both throw this error

heres the full error:

module.js:328
    throw err;
    ^

Error: Cannot find module 'unicode/category/So'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at symbols (/home/username/lib/node_modules/slug/slug.js:6:16)
    at /home/username/lib/node_modules/slug/slug.js:199:5
    at Object.<anonymous> (/home/username/lib/node_modules/slug/slug.js:212:2)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/username/lib/config/mylib.js:4:12)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)

Wrong README on npmjs.com

On npmjs.com, the "lower" option is printed as "lowercase":

print(slug('I ♥ UNICODE', {lowercase: false}))

Cannot read property 'multicharmap'

On

var slug = require('slug');
slug.defaults.modes = 'rfc3986';

I got

TypeError: Cannot read property 'multicharmap' of undefined
at slug (/var/task/node_modules/slug/slug.js:21:57)

Any idea please?

gyp error with `npm install` on project with slug dependency

npm install on node 4.2.1

gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/jcovingt/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "/Users/jcovingt/.nvm/versions/node/v4.2.1/bin/node" "/Users/jcovingt/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/jcovingt/example-project/node_modules/slug/node_modules/unicode/node_modules/bufferstream/node_modules/buffertools
gyp ERR! node -v v4.2.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok

Add a license?

Would you be willing to add a license field to the package.json?

The npm package description has an error

print(slug('I ♥ UNICODE', {lowercase: false}))

In the first example on the npm page - the example code uses lowercase as the option name, but the correct one is lower

The readme on github is correct

slug(`***`) -> ''

Passing in strings such as *** result in an empty string result. Not sure if this desired behavior, but it seems like slug should never return an empty string.

Slug installation error, ubuntu server 13

When i try to install "slug" i get :

OSError: [Errno 28] No space left on device
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 2.6.32-042stab084.14
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /node/mongonative/node_modules/slug/node_modules/unicode/node_modules/bufferstream/node_modules/buffertools
gyp ERR! node -v v0.10.26
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm http GET https://registry.npmjs.org/minimatch
npm WARN optional dep failed, continuing [email protected]
root@vps58220:/node/mongonative# df -i
Filesystem      Inodes  IUsed  IFree IUse% Mounted on
/dev/simfs     1000000 102854 897146   11% /
none            131072      2 131070    1% /sys/fs/cgroup
none            131072     66 131006    1% /run
none            131072      4 131068    1% /run/lock
none            131072      1 131071    1% /run/shm
none            131072      3 131069    1% /run/user
root@vps58220:/node/mongonative# 
root@vps58220:/node/mongonative# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/simfs       10G  6.0G  4.1G  60% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            103M  1.1M  102M   2% /run
none            5.0M     0  5.0M   0% /run/lock
none            512M     0  512M   0% /run/shm
none            100M     0  100M   0% /run/user

So space should not be the issue , no ?
Any Idea whats wrong ?

C vs. C# produce same slug "c"

This is causing a duplicate key error in my database.

C# is slugified to c, which conflicts with slug for C. Is there anyway to override this? Like maybe replacing # with sharp or pound.

Striping punctuations

Hello,

thanks for your module. It works really really well :-)
Except that at some point, it keeps some chars which are unusual for slugs.

Actually Devil May Cry 3 : l'Eveil de Dante is converted as devil-may-cry-3-:-l'eveil-de-dante. It would be cleaner to be converted as devil-may-cry-3-leveil-de-dante.

Do you have any plan to support that? Or do you recommend a nice way to achieve such a result?

Can't downloading unicode files

Windows 8.1
v0.12.6

E:\Vagrant\Ubuntu1404\testApp\api\node_modules\slug\node_modules\unicode\node_modules\bufferstream\node_modules\buffertools>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(44,5): error MSB8020: The builds tools for v120 (Platform Toolset = 'v120') cannot  be found. To build using the v120 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v120 to bu ild using the v120 build tools. [E:\Vagrant\Ubuntu1404\testApp\api\node_modules\slug\node_modules\unicode\node_modules\bufferstream\node_modules\buffertools\b uild\buffertools.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\Vagrant\Ubuntu1404\testApp\api\node_modules\slug\node_modules\unicode\node_modules\bufferstream\node_modules\buffertools
gyp ERR! node -v v0.12.6
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]

> [email protected] postinstall E:\Vagrant\Ubuntu1404\testApp\api\node_modules\slug\node_modules\unicode
> node install.js

try to read file /usr/share/unicode/UnicodeData.txt …
Warning: using slow naiv Buffer.indexOf function!
`npm install buffertools` to speed things up.
/usr/share/unicode/UnicodeData.txt not found.
try to read file /usr/share/unicode-data/UnicodeData.txt …
/usr/share/unicode-data/UnicodeData.txt not found.
try to read file UnicodeData.txt …
UnicodeData.txt not found.
try to download …
GET unicode.org:80/Public/UNIDATA/UnicodeData.txt
fetching …
.get() is deprecated. Access using array indexes instead.
saving data as Cc.js …
saving data as Zs.js …
saving data as Po.js …
saving data as Sc.js …
saving data as Ps.js …
saving data as Pe.js …
saving data as Sm.js …
saving data as Pd.js …
saving data as Nd.js …
saving data as Lu.js …
saving data as Sk.js …
saving data as Pc.js …
saving data as Ll.js …
saving data as So.js …
saving data as Lo.js …
saving data as Pi.js …
saving data as Cf.js …
saving data as No.js …
saving data as Pf.js …

The process can't download all files. The process is hanging.

Module maintenance

@dodo

With over 60k downloads per month and nearly 550 stars, I think the community has shown we love the work you've done! ❤️

That said, if you would like help with this module's maintenance, I'd be willing to triage issues and pull requests.


I have created a fork with support for Node 6 and various other changes.

Convert input to String

the function seems to return nothing if an integer is passed in. Should we convert the input to a string before slugifying?

Failed to slug Arabic/RTL text

  const text = 'لماذا نعيش؟';
  const print = console.log.bind(console, '>');
  print('text to slug: ', text);  // > لماذا نعيش؟
  print('text slugged: ', slug(text));  // > undefined
  print('text really slugged: ', slug(text, {lowercase: false}));    // > undefined

Vulnerable Regular Expression

The following regular expression used in parsing the input string is vulnerable to ReDoS:

/^\s+|\s+$/g

The slowdown is moderately low: for 50.000 characters around 2 seconds matching time. However, I would still suggest one of the following:

  • remove the regex,
  • anchor the regex,
  • limit the number of characters that can be matched by the repetition,
  • limit the input size.

If needed, I can provide an actual example showing the slowdown.

Dependency chain preventing use on node 6 - get rid of bufferjs all the way at the bottom

node-slug > unicode > bufferstream > bufferjs

bufferjs last updated 4 years ago, it adds all of ~90 apparently deprecated lines of code. @dodo since you are managing all the packages between this and that, is there any reason you can't simply include something else? My entire app failing to install because of slug (because of unicode (because of bufferstream (because of bufferjs))) is pretty annoying =/

coolaj86/node-bufferjs#13

Option for Camel Casing

Hi there

Do you think you could add a toCamelCase next to toLowerCase?

So that

slug('/video/create').toCamelCasel()

results into 'videoCreate'?

Thx!

Update docs on `options.lower`

The example uses the old options.lowercase which doesn't work anymore and has seemed to have moved to options.lower

options.lower also defaults to false now which seems a bit backwards but in any case, the docs should be corrected.

Feature suggestion: optionally add padding to mapped words

adding

if(opts.padMappedWords && char.length >1) char=' '+char+' '

after the chars have been mapped would allow

slug('m&m');  //=> 'mandm'
slug('i♥u');  //=> 'iloveu'

slug('m&m',{padMappedWords:true});  //=> 'm-and-m'
slug('i♥u',{padMappedWords:true}); //=> 'i-love-u'

Ignore specific characters

Is there a way to ignore certain characters? Specifically, I'm using this to clean up some image names, but I don't want to remove the period between the filename and extension, would be nice to just ignore periods.

Thanks

Docs out of sync

The docs on Github and npm are out of sync.

The npm docs (still?) tell you to set the "lowercase" options property to true in order to convert the slug to lower case, even though it's actually "lower" in the code, which is confusing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.