From 39e861d02d959ba99d0632af994ab48d4a8eeb14 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Sun, 12 Jan 2025 18:04:35 -0800 Subject: [PATCH] Add docs for `pathToRegexp` keys (#340) --- Readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index a0f9698..321c057 100644 --- a/Readme.md +++ b/Readme.md @@ -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) @@ -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)