# murl

> murl is fast url pattern matching and replacing

Latest version **0.4.1** (published 2013-09-20) · 0 weekly downloads

## Install

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

## 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.4.1 |
| Published | 2013-09-20 |
| First published | 2012-10-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mathias Buus Madsen |
| Maintainers | mafintosh |
| Keywords | url, routing, pattern, matching, match, replace |

## Links

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

## 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

- 0.4.1 (latest) — 2013-09-20
- 0.4.0 — 2013-09-20
- 0.3.0 — 2013-09-19
- 0.2.0 — 2012-11-12
- 0.1.4 — 2012-10-19
- 0.1.3 — 2012-10-18
- 0.1.2 — 2012-10-16
- 0.1.1 — 2012-10-15
- 0.1.0 — 2012-10-15

## README

# murl

murl is fast url pattern matching and replacing.
It's avaiable through npm:

	npm install murl

## What?

murl exposes a single function that accepts a pattern

``` js
var murl = require('murl');
var pattern = murl('/{hello}');
```

If you pass a string to the pattern murl will try and match it

``` js
pattern('/world') // -> {hello:'world'}
```

If you pass an object it will replace into the pattern

``` js
pattern({hello:'world'}) // -> '/world'
```

## Patterns

You can use `?` to specify a group as optional

`murl('/{hello}/{world}?')`: matches both `/a` and `/a/b`

Per default the `{}` groups matches until the next character or `/`.

`murl(/{hello})`: matches `/a` but not `/a/b`
`murl(/{wid}x{hei})`: matches `/200x200`

Use `*` to match anything

`murl('/*')`: matches `/a`, `/a/b/c` and so on

## Strict mode

Per default murl will disregard trailing `/` from the input string.
Pass `{strict:true}` to disable this.

``` js
var pattern = murl('/{hello}', {strict:true});

console.log(pattern('/world/')); // returns null
console.log(pattern('/world'))   // return {hello:'world'}
```

## License

MIT

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