Skip to content

Commit

Permalink
Add docs for pathToRegexp keys
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Nov 27, 2024
1 parent d63f44b commit 35bd84c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const fn = match("/foo/:bar");

## PathToRegexp

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

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

```js
const { regexp, keys } = pathToRegexp("/foo/:bar");

regexp.exec("/foo/123"); //=> ["/foo/123", "123"]
```

## Compile ("Reverse" Path-To-RegExp)
Expand Down

0 comments on commit 35bd84c

Please sign in to comment.