New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sluggo

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sluggo

High-speed, unicode-aware, browser-friendly slug generator

0.1.2
Source
npm
Version published
Maintainers
1
Created
Source

sluggo

sluggo is a slug generator that:

  • Understands Unicode
  • Runs fast (much, much faster than a RegExp solution)
  • Replaces all runs of punctuation (in any language), control characters, whitespace, etc. with single dashes, with no leading or trailing dashes
  • Allows you to let one punctuation character through if you wish, such as a slash for pathnames
  • Allows you to change the separator character
  • Is small enough to include in your browser javascript (<10K), even with the Unicode data

Installation

npm install sluggo

Usage

var sluggo = require('sluggo');

var s = sluggo('@ monkey\'s are elab؉؉orate fools##');
console.log(s);

Outputs:

monkey-s-are-elab-orate-fools

You can change the separator and specify a single punctuation character to be tolerated:

var sluggo = require('sluggo');

var s = sluggo('@ monkey\'s are elab؉؉orate fools##', { separator: ',', allowed: '؉'});
console.log(s);

Outputs:

monkey,s,are,elab؉؉orate,fools

In the Browser

You just want sluggo.js. Add that file to your frontend javascript world.

Now you can call the sluggo() function anywhere.

You do NOT need generator.js, which we will use when the next version of Unicode comes out to update this module.

About P'unk Avenue and Apostrophe

sluggo was created at P'unk Avenue for use in many projects built with Apostrophe, an open-source content management system built on node.js. If you like sluggo you should definitely check out apostrophenow.org.

Support

Feel free to open issues on github.

Changelog

CHANGES IN 0.1.2

Converts to lowercase properly.

CHANGES IN 0.1.1

Packaged correctly to work in either node or the browser.

CHANGES IN 0.1.0

Initial release.

Keywords

slug

FAQs

Package last updated on 08 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts