Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slugger

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

slugger

Takes a string, returns a url friendly string. Works in browser and node. Dead simple.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
496
increased by39.33%
Maintainers
1
Weekly downloads
 
Created
Source

slugger

Dead simple slugification for node and browser.

What it does:

Converts any string into a url friendly veresion:

slugger('Hello yOu CRAZY Swede!'); // returns 'hello-you-crazy-swede'

// optionally maintain case
slugger('Hello yOu CRAZY Swede!', {maintainCase: true}); // returns 'Hello-yOu-CRAZY-Swede'

// optionally use a different replacement character
slugger('Hello yOu CRAZY Swede!', {replacement: '_'}); // returns 'hello_you_crazy_swede'

// optionally trim to max length while not breaking any words
slugger('Hello yOu CRAZY Swede!', {smartTrim: 9}); // returns 'hello-you'

That's all there is to it!

Installing

npm install slugger

Or just grab the slugger.js file and drop it into your project.

It also plays nicely with: https://github.com/henrikjoreteg/clientmodules

Why did I write this when there's already https://github.com/dodo/node-slug ?

Because I wanted something simpler that didn't try to do anything with special characters or unicode and I wanted something that worked well in the browser or node.

Tests?

yup.

Dig it?

Then you should probably follow @HenrikJoreteg on twitter.

License

MIT

FAQs

Package last updated on 18 Jun 2013

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc