Skip to content

Commit 1628bb7

Browse files
author
Muhammad Usman
committed
Merge pull request pillarjs#1 from ForbesLindesay/docs
Add documentation
2 parents c5a51c4 + 9363fca commit 1628bb7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@
33

44
Turn an Express-style path string such as `/user/:name` into a regular expression.
55

6+
## Usage
7+
8+
```javascript
9+
var pathToRegexp = require('path-to-regexp');
10+
```
11+
### pathToRegexp(path, keys, options)
12+
13+
- **path** A string in the express format, an array of such strings, or a regular expression
14+
- **keys** An array to be populated with the keys present in the url. Once the function completes, this will be an array of strings.
15+
- **options**
16+
- **options.sensitive** Defaults to false, set this to true to make routes case sensitive
17+
- **options.strict** Defaults to false, set this to true to make the trailing slash matter.
18+
19+
```javascript
20+
var keys = [];
21+
var exp = pathToRegexp('/foo/:bar', keys);
22+
//keys = ['bar']
23+
//exp = /^\/foo\/(?:([^\/]+?))\/?$/i
24+
```
25+
26+
## Live Demo
27+
28+
You can see a live demo of this library in use at [express-route-tester](http://forbeslindesay.github.com/express-route-tester/).
29+
630
## License
731

832
MIT

0 commit comments

Comments
 (0)