# pathname-router

> a simple pathname router

Latest version **0.0.5** (published 2016-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install pathname-router
pnpm add pathname-router
yarn add pathname-router
bun add pathname-router
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2016-12-20 |
| First published | 2016-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jared Grippe |
| Maintainers | deadlyicon |

## Links

- npm: https://www.npmjs.com/package/pathname-router
- Repository: https://github.com/deadlyicon/pathname-router
- Homepage: https://github.com/deadlyicon/pathname-router#readme
- Issues: https://github.com/deadlyicon/pathname-router/issues
- npm.io page: https://npm.io/package/pathname-router

## Dependencies (1)

- [path-to-regexp](https://npm.io/package/path-to-regexp.md) ^1.6.0

## Recent versions

- 0.0.5 (latest) — 2016-12-20
- 0.0.4 — 2016-12-20
- 0.0.3 — 2016-10-08
- 0.0.2 — 2016-10-03
- 0.0.1 — 2016-10-03

## README

# pathname-router


The route expressions are parsed with https://github.com/pillarjs/path-to-regexp


## Usage

```js
import PathnameRouter from 'pathname-router'

const router = new PathnameRouter

router.map('/',              {name: 'HomePage'})
router.map('/about',         {name: 'AboutPage'})
router.map('/posts/:postId', {name: 'PostShowPage'})
router.map('/:path*',        {name: 'CatchAllPage'})

router.resolve({pathname: '/'})
// => {name: 'HomePage'}

router.resolve({pathname: '/about'})
// => {name: 'AboutPage'}

router.resolve({pathname: '/posts/1234'})
// => {name: 'PostShowPage', postId: '1234'}

router.resolve({pathname: '/bad/path'})
// => {name: 'CatchAllPage', path: 'bad/path'}
````

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