# martinetto

> A modular, functional JS route parser micro library

Latest version **1.1.3** (published 2016-01-27) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2016-01-27 |
| First published | 2016-01-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Janne Liuhtonen |
| Maintainers | jliuhtonen |
| Keywords | route, parser, micro-library |

## Links

- npm: https://www.npmjs.com/package/martinetto
- Repository: https://github.com/jliuhtonen/martinetto.js
- Homepage: https://github.com/jliuhtonen/martinetto.js#readme
- Issues: https://github.com/jliuhtonen/martinetto.js/issues
- npm.io page: https://npm.io/package/martinetto

## Dependencies (1)

- [escape-string-regexp](https://npm.io/package/escape-string-regexp.md) ^1.0.3

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2016-01-27
- 1.1.2 — 2016-01-26

## README

# martinetto.js
[![Build Status](https://travis-ci.org/jliuhtonen/martinetto.js.svg?branch=master)](https://travis-ci.org/jliuhtonen/martinetto.js)

Martinetto.js is a micro-library for parsing and matching relative url paths or _routes_. It supports named path parameters and multiple wildcards. It also parses the fragment and query parts for matched routes.

## Usage

```javascript
> const Martinetto = require('./dist/martinetto')
> const routeMatcher = Martinetto.routing([
  { 
    route: '/artists/:name/album/:albumName', 
    fn: (routeData) => {
      console.log(routeData)
      return 'Album page'
    } 
  },
  { 
    route: '/artists/:name/*', 
    fn: (routeData) =>  {
      console.log(routeData)
      return 'Artist page'
    } 
  }
])
> routeMatcher('/artists/Aphex%20Twin/album/Syro')
{ path: '/artists/Aphex%20Twin/album/Syro',
  fragment: '',
  queryParams: {},
  pathParams: { name: 'Aphex Twin', albumName: 'Syro' },
  wildcards: [] }
'Album page'
> routeMatcher('/artists/Aphex%20Twin/gigs')
{ path: '/artists/Aphex%20Twin/gigs',
  fragment: '',
  queryParams: {},
  pathParams: { name: 'Aphex Twin' },
  wildcards: [ 'gigs' ] }
'Artist page'
```

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