@@ -20,7 +20,7 @@ npm install path-to-regexp --save
2020``` javascript
2121const pathToRegexp = require (' path-to-regexp' )
2222
23- // pathToRegexp(path, keys?, options?)
23+ // pathToRegexp.pathToRegexp (path, keys?, options?)
2424// pathToRegexp.match(path)
2525// pathToRegexp.parse(path)
2626// pathToRegexp.compile(path)
@@ -39,7 +39,7 @@ const pathToRegexp = require('path-to-regexp')
3939
4040``` javascript
4141const keys = []
42- const regexp = pathToRegexp (' /foo/:bar' , keys)
42+ const regexp = pathToRegexp . pathToRegexp (' /foo/:bar' , keys)
4343// regexp = /^\/foo\/([^\/]+?)\/?$/i
4444// keys = [{ name: 'bar', prefix: '/', delimiter: '/', optional: false, repeat: false, pattern: '[^\\/]+?' }]
4545```
@@ -55,7 +55,7 @@ The path argument is used to define parameters and populate the list of keys.
5555Named parameters are defined by prefixing a colon to the parameter name (` :foo ` ). By default, the parameter will match until the next prefix (e.g. ` [^/]+ ` ).
5656
5757``` js
58- const regexp = pathToRegexp (' /:foo/:bar' )
58+ const regexp = pathToRegexp . pathToRegexp (' /:foo/:bar' )
5959// keys = [{ name: 'foo', prefix: '/', ... }, { name: 'bar', prefix: '/', ... }]
6060
6161regexp .exec (' /test/route' )
@@ -71,7 +71,7 @@ regexp.exec('/test/route')
7171Parameters can be suffixed with a question mark (` ? ` ) to make the parameter optional.
7272
7373``` js
74- const regexp = pathToRegexp (' /:foo/:bar?' )
74+ const regexp = pathToRegexp . pathToRegexp (' /:foo/:bar?' )
7575// keys = [{ name: 'foo', ... }, { name: 'bar', delimiter: '/', optional: true, repeat: false }]
7676
7777regexp .exec (' /test' )
@@ -88,7 +88,7 @@ regexp.exec('/test/route')
8888Parameters can be suffixed with an asterisk (` * ` ) to denote a zero or more parameter matches. The prefix is used for each match.
8989
9090``` js
91- const regexp = pathToRegexp (' /:foo*' )
91+ const regexp = pathToRegexp . pathToRegexp (' /:foo*' )
9292// keys = [{ name: 'foo', delimiter: '/', optional: true, repeat: true }]
9393
9494regexp .exec (' /' )
@@ -103,7 +103,7 @@ regexp.exec('/bar/baz')
103103Parameters can be suffixed with a plus sign (` + ` ) to denote a one or more parameter matches. The prefix is used for each match.
104104
105105``` js
106- const regexp = pathToRegexp (' /:foo+' )
106+ const regexp = pathToRegexp . pathToRegexp (' /:foo+' )
107107// keys = [{ name: 'foo', delimiter: '/', optional: false, repeat: true }]
108108
109109regexp .exec (' /' )
@@ -118,7 +118,7 @@ regexp.exec('/bar/baz')
118118It is possible to write an unnamed parameter that only consists of a matching group. It works the same as a named parameter, except it will be numerically indexed.
119119
120120``` js
121- const regexp = pathToRegexp (' /:foo/(.*)' )
121+ const regexp = pathToRegexp . pathToRegexp (' /:foo/(.*)' )
122122// keys = [{ name: 'foo', ... }, { name: 0, ... }]
123123
124124regexp .exec (' /test/route' )
@@ -130,7 +130,7 @@ regexp.exec('/test/route')
130130All parameters can have a custom regexp, which overrides the default match (` [^/]+ ` ). For example, you can match digits or names in a path:
131131
132132``` js
133- const regexpNumbers = pathToRegexp (' /icon-:foo(\\ d+).png' )
133+ const regexpNumbers = pathToRegexp . pathToRegexp (' /icon-:foo(\\ d+).png' )
134134// keys = [{ name: 'foo', ... }]
135135
136136regexpNumbers .exec (' /icon-123.png' )
@@ -139,7 +139,7 @@ regexpNumbers.exec('/icon-123.png')
139139regexpNumbers .exec (' /icon-abc.png' )
140140// => null
141141
142- const regexpWord = pathToRegexp (' /(user|u)' )
142+ const regexpWord = pathToRegexp . pathToRegexp (' /(user|u)' )
143143// keys = [{ name: 0, ... }]
144144
145145regexpWord .exec (' /u' )
0 commit comments