File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 3
3
4
4
Turn an Express-style path string such as ` /user/:name ` into a regular expression.
5
5
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
+
6
30
## License
7
31
8
32
MIT
You can’t perform that action at this time.
0 commit comments