@@ -57,8 +57,8 @@ Named parameters are defined by prefixing a colon to the parameter name (`:foo`)
57
57
const regexp = pathToRegexp (' /:foo/:bar' )
58
58
// keys = [{ name: 'foo', prefix: '/', ... }, { name: 'bar', prefix: '/', ... }]
59
59
60
- re .exec (' /test/route' )
61
- // => ['/test/route', 'test', 'route']
60
+ regexp .exec (' /test/route' )
61
+ // => [ '/test/route', 'test', 'route', index: 0, input: '/test/route', groups: undefined ]
62
62
```
63
63
64
64
** Please note:** Parameter names must use "word characters" (` [A-Za-z0-9_] ` ).
@@ -73,11 +73,11 @@ Parameters can be suffixed with a question mark (`?`) to make the parameter opti
73
73
const regexp = pathToRegexp (' /:foo/:bar?' )
74
74
// keys = [{ name: 'foo', ... }, { name: 'bar', delimiter: '/', optional: true, repeat: false }]
75
75
76
- re .exec (' /test' )
77
- // => ['/test', 'test', undefined]
76
+ regexp .exec (' /test' )
77
+ // => [ '/test', 'test', undefined, index: 0, input: '/test', groups: undefined ]
78
78
79
- re .exec (' /test/route' )
80
- // => ['/test', 'test', 'route']
79
+ regexp .exec (' /test/route' )
80
+ // => [ '/test/route ', 'test', 'route', index: 0, input: '/test/route', groups: undefined ]
81
81
```
82
82
83
83
** Tip:** The prefix is also optional, escape the prefix ` \/ ` to make it required.
@@ -90,11 +90,11 @@ Parameters can be suffixed with an asterisk (`*`) to denote a zero or more param
90
90
const regexp = pathToRegexp (' /:foo*' )
91
91
// keys = [{ name: 'foo', delimiter: '/', optional: true, repeat: true }]
92
92
93
- re .exec (' /' )
94
- // => ['/', undefined]
93
+ regexp .exec (' /' )
94
+ // => [ '/', undefined, index: 0, input: '/', groups: undefined ]
95
95
96
- re .exec (' /bar/baz' )
97
- // => ['/bar/baz', 'bar/baz']
96
+ regexp .exec (' /bar/baz' )
97
+ // => [ '/bar/baz', 'bar/baz', index: 0, input: '/bar/baz', groups: undefined ]
98
98
```
99
99
100
100
##### One or more
@@ -109,8 +109,7 @@ regexp.exec('/')
109
109
// => null
110
110
111
111
regexp .exec (' /bar/baz' )
112
- // => ['/bar/baz', 'bar/baz']
113
- ```
112
+ // => [ '/bar/baz','bar/baz', index: 0, input: '/bar/baz', groups: undefined ]
114
113
115
114
#### Unnamed Parameters
116
115
@@ -121,7 +120,7 @@ const regexp = pathToRegexp('/:foo/(.*)')
121
120
// keys = [{ name: 'foo', ... }, { name: 0, ... }]
122
121
123
122
regexp.exec('/test/route')
124
- // => ['/test/route', 'test', 'route']
123
+ //=> [ '/test/route', 'test', 'route', index: 0, input: '/test/route', groups: undefined ]
125
124
` ` `
126
125
127
126
#### Custom Matching Parameters
0 commit comments