Skip to content

Commit 35bd84c

Browse files
committed
Add docs for pathToRegexp keys
1 parent d63f44b commit 35bd84c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Readme.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const fn = match("/foo/:bar");
7878

7979
## PathToRegexp
8080

81-
The `pathToRegexp` function returns a regular expression for matching strings against paths. It
81+
The `pathToRegexp` function returns the `regexp` for matching strings against paths, and an array of `keys` for understanding the `RegExp#exec` matches.
8282

8383
- **path** String or array of strings.
8484
- **options** _(optional)_ (See [parse](#parse) for more options)
@@ -89,6 +89,8 @@ The `pathToRegexp` function returns a regular expression for matching strings ag
8989

9090
```js
9191
const { regexp, keys } = pathToRegexp("/foo/:bar");
92+
93+
regexp.exec("/foo/123"); //=> ["/foo/123", "123"]
9294
```
9395

9496
## Compile ("Reverse" Path-To-RegExp)

0 commit comments

Comments
 (0)