# url-path-sanitizer

> Sanitizes ids from url paths

Latest version **1.0.1** (published 2020-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install url-path-sanitizer
pnpm add url-path-sanitizer
yarn add url-path-sanitizer
bun add url-path-sanitizer
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-06-09 |
| First published | 2018-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | jae.b.bradley@gmail.com |
| Maintainers | jaebradley |
| Keywords | url, sanitization, paths, url paths |

## Links

- npm: https://www.npmjs.com/package/url-path-sanitizer
- Repository: https://github.com/jaebradley/url-path-sanitizer
- Homepage: https://github.com/jaebradley/url-path-sanitizer#readme
- Issues: https://github.com/jaebradley/url-path-sanitizer/issues
- npm.io page: https://npm.io/package/url-path-sanitizer

## Dependencies (1)

- [has-a-digit](https://npm.io/package/has-a-digit.md) ^1.0.1

## 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) — 2020-06-09
- 1.0.0 — 2018-07-14

## README

[![Greenkeeper badge](https://badges.greenkeeper.io/jaebradley/url-path-sanitizer.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/jaebradley/url-path-sanitizer.svg?branch=master)](https://travis-ci.org/jaebradley/url-path-sanitizer)
[![codecov](https://codecov.io/gh/jaebradley/url-path-sanitizer/branch/master/graph/badge.svg)](https://codecov.io/gh/jaebradley/url-path-sanitizer)
[![npm](https://img.shields.io/npm/v/url-path-sanitizer.svg)](https://www.npmjs.com/package/url-path-sanitizer)
[![npm](https://img.shields.io/npm/dt/url-path-sanitizer.svg)](https://www.npmjs.com/package/url-path-sanitizer)

# url-path-sanitizer

Strip any URL path part with a digit and replace with a placeholder

## Installation

```bash
npm install url-path-sanitizer
```

```bash
yarn add url-path-sanitizer
```

## Usage

### `urlPathSanitizer`

* `url` property is the URL to sanitize - this property is required
* `placeholder` - value to replace url path parts with digits. Default is `[:id]`
* `whitelist` - values to ignore when evaluating if it contains a digit

```javascript
import urlPathSanitizer from 'url-path-sanitizer';

urlPathSanitizer({ url: '/some/path/with/an/id/1' }); // /some/path/with/an/[:id]
urlPathSanitizer({ url: '/another/path/with/an/id/1', placeholder: 'jae' }); // /another/path/with/an/id/jae
urlPathSanitizer({ url: '/a/path/without/a/digit' }); // /a/path/without/a/digit
urlPathSanitizer({ url: '/v1/some/whitelisted/path', whitelist: ['v1'] }); // /v1/some/whitelisted/path
```

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