Skip to content

Commit b5156c8

Browse files
Matthew de Haastblakeembrey
authored andcommitted
chore(readme): Update readme for correctness (#179)
1 parent fa00e6b commit b5156c8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

Readme.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ Named parameters are defined by prefixing a colon to the parameter name (`:foo`)
5757
const regexp = pathToRegexp('/:foo/:bar')
5858
// keys = [{ name: 'foo', prefix: '/', ... }, { name: 'bar', prefix: '/', ... }]
5959

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 ]
6262
```
6363

6464
**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
7373
const regexp = pathToRegexp('/:foo/:bar?')
7474
// keys = [{ name: 'foo', ... }, { name: 'bar', delimiter: '/', optional: true, repeat: false }]
7575

76-
re.exec('/test')
77-
//=> ['/test', 'test', undefined]
76+
regexp.exec('/test')
77+
//=> [ '/test', 'test', undefined, index: 0, input: '/test', groups: undefined ]
7878

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 ]
8181
```
8282

8383
**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
9090
const regexp = pathToRegexp('/:foo*')
9191
// keys = [{ name: 'foo', delimiter: '/', optional: true, repeat: true }]
9292

93-
re.exec('/')
94-
//=> ['/', undefined]
93+
regexp.exec('/')
94+
//=> [ '/', undefined, index: 0, input: '/', groups: undefined ]
9595

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 ]
9898
```
9999

100100
##### One or more
@@ -109,8 +109,7 @@ regexp.exec('/')
109109
//=> null
110110

111111
regexp.exec('/bar/baz')
112-
//=> ['/bar/baz', 'bar/baz']
113-
```
112+
//=> [ '/bar/baz','bar/baz', index: 0, input: '/bar/baz', groups: undefined ]
114113

115114
#### Unnamed Parameters
116115

@@ -121,7 +120,7 @@ const regexp = pathToRegexp('/:foo/(.*)')
121120
// keys = [{ name: 'foo', ... }, { name: 0, ... }]
122121
123122
regexp.exec('/test/route')
124-
//=> ['/test/route', 'test', 'route']
123+
//=> [ '/test/route', 'test', 'route', index: 0, input: '/test/route', groups: undefined ]
125124
```
126125

127126
#### Custom Matching Parameters

0 commit comments

Comments
 (0)