|
3 | 3 | > Turn a path string such as `/user/:name` into a regular expression. |
4 | 4 |
|
5 | 5 | [![NPM version][npm-image]][npm-url] |
6 | | -[![Build status][travis-image]][travis-url] |
7 | | -[![Test coverage][coveralls-image]][coveralls-url] |
8 | | -[![Dependency Status][david-image]][david-url] |
| 6 | +[![NPM downloads][downloads-image]][downloads-url] |
| 7 | +[![Build status][build-image]][build-url] |
| 8 | +[![Build coverage][coverage-image]][coverage-url] |
9 | 9 | [![License][license-image]][license-url] |
10 | | -[![Downloads][downloads-image]][downloads-url] |
11 | 10 |
|
12 | 11 | ## Installation |
13 | 12 |
|
@@ -201,15 +200,17 @@ fn("/user/caf%C3%A9"); //=> { path: '/user/caf%C3%A9', index: 0, params: { id: ' |
201 | 200 | The `match` function can be used to custom match named parameters. For example, this can be used to whitelist a small number of valid paths: |
202 | 201 |
|
203 | 202 | ```js |
204 | | -const urlMatch = match("/users/:id/:tab(home|photos|bio)", { decode: decodeURIComponent }); |
| 203 | +const urlMatch = match("/users/:id/:tab(home|photos|bio)", { |
| 204 | + decode: decodeURIComponent, |
| 205 | +}); |
205 | 206 |
|
206 | | -urlMatch("/users/1234/photos") |
| 207 | +urlMatch("/users/1234/photos"); |
207 | 208 | //=> { path: '/users/1234/photos', index: 0, params: { id: '1234', tab: 'photos' } } |
208 | 209 |
|
209 | | -urlMatch("/users/1234/bio") |
| 210 | +urlMatch("/users/1234/bio"); |
210 | 211 | //=> { path: '/users/1234/bio', index: 0, params: { id: '1234', tab: 'bio' } } |
211 | 212 |
|
212 | | -urlMatch("/users/1234/otherstuff") |
| 213 | +urlMatch("/users/1234/otherstuff"); |
213 | 214 | //=> false |
214 | 215 | ``` |
215 | 216 |
|
@@ -340,15 +341,13 @@ You can see a live demo of this library in use at [express-route-tester](http:// |
340 | 341 |
|
341 | 342 | MIT |
342 | 343 |
|
343 | | -[npm-image]: https://img.shields.io/npm/v/path-to-regexp.svg?style=flat |
| 344 | +[npm-image]: https://img.shields.io/npm/v/path-to-regexp |
344 | 345 | [npm-url]: https://npmjs.org/package/path-to-regexp |
345 | | -[travis-image]: https://img.shields.io/travis/pillarjs/path-to-regexp.svg?style=flat |
346 | | -[travis-url]: https://travis-ci.org/pillarjs/path-to-regexp |
347 | | -[coveralls-image]: https://img.shields.io/coveralls/pillarjs/path-to-regexp.svg?style=flat |
348 | | -[coveralls-url]: https://coveralls.io/r/pillarjs/path-to-regexp?branch=master |
349 | | -[david-image]: http://img.shields.io/david/pillarjs/path-to-regexp.svg?style=flat |
350 | | -[david-url]: https://david-dm.org/pillarjs/path-to-regexp |
| 346 | +[downloads-image]: https://img.shields.io/npm/dm/path-to-regexp |
| 347 | +[downloads-url]: https://npmjs.org/package/path-to-regexp |
| 348 | +[build-image]: https://img.shields.io/github/workflow/status/pillarjs/path-to-regexp/CI/master |
| 349 | +[build-url]: https://github.com/pillarjs/path-to-regexp/actions/workflows/ci.yml?query=branch%3Amaster |
| 350 | +[coverage-image]: https://img.shields.io/codecov/c/gh/pillarjs/path-to-regexp |
| 351 | +[coverage-url]: https://codecov.io/gh/pillarjs/path-to-regexp |
351 | 352 | [license-image]: http://img.shields.io/npm/l/path-to-regexp.svg?style=flat |
352 | 353 | [license-url]: LICENSE.md |
353 | | -[downloads-image]: http://img.shields.io/npm/dm/path-to-regexp.svg?style=flat |
354 | | -[downloads-url]: https://npmjs.org/package/path-to-regexp |
0 commit comments