# slugg

> Make strings url safe (with no dependencies)

Latest version **1.2.1** (published 2017-05-31) · BSD license · 0 weekly downloads

## Install

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

## 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.2.1 |
| Published | 2017-05-31 |
| First published | 2012-11-30 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 364 |
| Author | Ben Gourley |
| Maintainers | bengourley |
| Keywords | slug, url, string |

## Links

- npm: https://www.npmjs.com/package/slugg
- Repository: https://github.com/bengourley/slugg
- Homepage: https://github.com/bengourley/slugg#readme
- Issues: https://github.com/bengourley/slugg/issues
- npm.io page: https://npm.io/package/slugg

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.2.1 (latest) — 2017-05-31
- 1.2.0 — 2017-03-15
- 1.1.0 — 2016-11-30
- 1.0.0 — 2016-02-19
- 0.1.2 — 2013-06-24
- 0.1.1 — 2013-06-14
- 0.1.0 — 2013-04-22
- 0.0.1 — 2012-12-03
- 0.0.0 — 2012-11-30

## README

# Slugg

Make strings url-safe.

- Comprehensive tests
- No dependencies
- Not in coffee-script (lol)
- Coerces foreign symbols to their english equivalent
- Doesn't try to do anything fancy with symbols (just removes them)
- Works in browser (`window.slugg`) and AMD/CommonJS-flavoured module loaders

```
npm install slugg
```

## Usage:

### slug(string, [separator, toStrip])

```js
var slug = require('slugg')

slug('My fantastic blog post')
//-> 'my-fantastic-blog-post'

slug('Today I found £5')
//-> 'today-i-found-5'

slug('I ♥ you')
//-> 'i-you'
```

If you want a separator other than '-', pass it in as the second argument:

```js
slug('Kevin Spacey', ' ')
//-> 'kevin spacey'
```

By default, slugg will strip (i.e. remove and not replace) any sort of quotemark: `'"’‘”“`.

If you want to control which characters are stripped, pass a regex as the last option
that will match the chars you want to replace, eg:

```js
slug('Mum\'s cooking', /'/g)
//-> 'mums-cooking'
```

Remember to use the `g` flag if you want all the matches stripped (not just the first).

After version 1.1.0, a new syntax has been introduced:

### slug(string, [options])

If you want a separator other than '-', pass it in as the `separator` option:

```js
slug('Kevin Spacey', { separator: ' ' })
//-> 'kevin spacey'
```

If you want to control which characters are stripped, pass a regex as the `toStrip` option
that will match the chars you want to replace, eg:

```js
slug('Mum\'s cooking', { toStrip: /'/g })
//-> 'mums-cooking'
```
Remember to use the `g` flag if you want all the matches stripped (not just the first).

By default, slugg will convert your string to lower case. If you want to disable it just
pass the `toLowerCase` option as `false`, eg:

```js
slug('Slugg rocks!', { toLowerCase: false })
//-> 'Slugg-rocks'
```

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