Skip to content

Commit fe901e6

Browse files
committed
Tidy up readme language
1 parent ce78ebb commit fe901e6

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Readme.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ var pathToRegexp = require('path-to-regexp')
2525
// pathToRegexp.compile(path)
2626
```
2727

28-
- **path** A string in the express format, an array of strings, or a regular expression.
29-
- **keys** An array to be populated with the keys present in the url.
28+
- **path** An Express-style string, an array of strings, or a regular expression.
29+
- **keys** An array to be populated with the keys found in the path.
3030
- **options**
3131
- **sensitive** When `true` the route will be case sensitive. (default: `false`)
3232
- **strict** When `false` the trailing slash is optional. (default: `false`)
@@ -41,11 +41,11 @@ var re = pathToRegexp('/foo/:bar', keys)
4141

4242
### Parameters
4343

44-
The path has the ability to define parameters and automatically populate the keys array.
44+
The path string can be used to define parameters and populate the keys.
4545

4646
#### Named Parameters
4747

48-
Named parameters are defined by prefixing a colon to the parameter name (`:foo`). By default, this parameter will match up to the next path segment.
48+
Named parameters are defined by prefixing a colon to the parameter name (`:foo`). By default, this parameter will match the following path segment.
4949

5050
```js
5151
var re = pathToRegexp('/:foo/:bar', keys)
@@ -59,7 +59,7 @@ re.exec('/test/route')
5959

6060
##### Optional
6161

62-
Parameters can be suffixed with a question mark (`?`) to make the entire parameter optional. This will also make any prefixed path delimiter optional (`/` or `.`).
62+
Parameters can be suffixed with a question mark (`?`) to make the parameter optional. This will also make any the prefixed path delimiter optional (`/` or `.`).
6363

6464
```js
6565
var re = pathToRegexp('/:foo/:bar?', keys)
@@ -74,7 +74,7 @@ re.exec('/test/route')
7474

7575
##### Zero or more
7676

77-
Parameters can be suffixed with an asterisk (`*`) to denote a zero or more parameter match. The prefixed path delimiter is also taken into account for the match.
77+
Parameters can be suffixed with an asterisk (`*`) to denote a zero or more parameter matches. The prefixed path delimiter is taken into account for each match.
7878

7979
```js
8080
var re = pathToRegexp('/:foo*', keys)
@@ -89,7 +89,7 @@ re.exec('/bar/baz')
8989

9090
##### One or more
9191

92-
Parameters can be suffixed with a plus sign (`+`) to denote a one or more parameters match. The prefixed path delimiter is included in the match.
92+
Parameters can be suffixed with a plus sign (`+`) to denote a one or more parameter matches. The prefixed path delimiter is taken into account for each match.
9393

9494
```js
9595
var re = pathToRegexp('/:foo+', keys)
@@ -104,7 +104,7 @@ re.exec('/bar/baz')
104104

105105
#### Custom Match Parameters
106106

107-
All parameters can be provided a custom matching regexp and override the default. Please note: Backslashes need to be escaped in strings.
107+
All parameters can be provided a custom regexp, which overrides the default (`[^\/]+`). Please note: Backslashes need to be escaped with another backslash in strings.
108108

109109
```js
110110
var re = pathToRegexp('/:foo(\\d+)', keys)
@@ -119,11 +119,11 @@ re.exec('/abc')
119119

120120
#### Unnamed Parameters
121121

122-
It is possible to write an unnamed parameter that is only a matching group. It works the same as a named parameter, except it will be numerically indexed.
122+
It 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.
123123

124124
```js
125125
var re = pathToRegexp('/:foo/(.*)', keys)
126-
// keys = [{ name: 'foo', ... }, { name: '0', ... }]
126+
// keys = [{ name: 'foo', ... }, { name: 0, ... }]
127127

128128
re.exec('/test/route')
129129
//=> ['/test/route', 'test', 'route']
@@ -143,7 +143,7 @@ re.exec('/foo/bar/baz')
143143

144144
### Parse
145145

146-
The parse function is exposed via `pathToRegexp.parse`. This will yield an array of strings and keys.
146+
The parse function is exposed via `pathToRegexp.parse`. This will return an array of strings and keys.
147147

148148
```js
149149
var tokens = pathToRegexp.parse('/route/:foo/(.*)')
@@ -158,11 +158,11 @@ console.log(tokens[2])
158158
//=> { name: 0, prefix: '/', delimiter: '/', optional: false, repeat: false, pattern: '.*' }
159159
```
160160

161-
**Note:** This method only works with strings.
161+
**Note:** This method only works with Express-style strings.
162162

163163
### Compile ("Reverse" Path-To-RegExp)
164164

165-
Path-To-RegExp exposes a compile function for transforming an express path into valid path. Confusing enough? This example will straighten everything out for you.
165+
Path-To-RegExp exposes a compile function for transforming an Express-style path into a valid path.
166166

167167
```js
168168
var toPath = pathToRegexp.compile('/user/:id')
@@ -183,7 +183,7 @@ toPathRegexp({ id: '123' }) //=> "/user/123"
183183
toPathRegexp({ id: 'abc' }) //=> throws TypeError
184184
```
185185

186-
**Note:** The generated function will throw on any invalid input. It will execute all necessary checks to ensure the generated path is valid. This method only works with strings.
186+
**Note:** The generated function will throw on invalid input. It will do all necessary checks to ensure the generated path is valid. This method only works with strings.
187187

188188
### Working with Tokens
189189

0 commit comments

Comments
 (0)