# slugger

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

Latest version **1.0.1** (published 2015-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install slugger
pnpm add slugger
yarn add slugger
bun add slugger
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-09-22 |
| First published | 2013-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Henrik Joreteg |
| Maintainers | fyockm, henrikjoreteg |
| Keywords | utils, browser, url |

## Links

- npm: https://www.npmjs.com/package/slugger
- Repository: https://github.com/henrikjoreteg/slugger
- Issues: https://github.com/henrikjoreteg/slugger/issues
- npm.io page: https://npm.io/package/slugger

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-09-22
- 1.0.0 — 2014-06-15
- 0.1.0 — 2014-02-06
- 0.0.3 — 2013-06-18
- 0.0.2 — 2013-05-20
- 0.0.1 — 2013-05-17

## README

# slugger

Dead simple slugification for node and browser.

## What it does:

Converts any string into a url friendly version:

```js
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'

// optionally allow additional characters
// just pass string of characters that would normally be removed
// that you want to allow.
slugger('Hello yOu CRAZY Swede!', {alsoAllow: "!&"}); // returns 'hello-you-crazy-swede!'

// decodes URI components by default, so {decode: true} is not required
slugger('boo%20boo') // returns 'boo-boo';
// now without decode
slugger('boo%20boo', {decode: false}) // returns boo20boo;

```

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? 

Just run `npm test`

## Changelog

- 0.1.0 - Adding option to allow other characters

## Dig it?

Then you should probably follow [@HenrikJoreteg](http://twitter.com/henrikjoreteg) on twitter.

## License
 
MIT

---
_Source: https://npm.io/package/slugger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
