path-to-regexp 7.1.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Readme.md CHANGED
@@ -17,208 +17,72 @@ npm install path-to-regexp --save
17
17
  ## Usage
18
18
 
19
19
  ```js
20
- const { pathToRegexp, match, parse, compile } = require("path-to-regexp");
20
+ const { match, compile, parse } = require("path-to-regexp");
21
21
 
22
- // pathToRegexp(path, options?)
23
22
  // match(path, options?)
24
- // parse(path, options?)
25
23
  // compile(path, options?)
24
+ // parse(path, options?)
26
25
  ```
27
26
 
28
- ### Path to regexp
29
-
30
- The `pathToRegexp` function returns a regular expression with `keys` as a property. It accepts the following arguments:
31
-
32
- - **path** A string.
33
- - **options** _(optional)_
34
- - **sensitive** Regexp will be case sensitive. (default: `false`)
35
- - **trailing** Allows optional trailing delimiter to match. (default: `true`)
36
- - **strict** Verify patterns are valid and safe to use. (default: `false`, recommended: `true`)
37
- - **end** Match to the end of the string. (default: `true`)
38
- - **start** Match from the beginning of the string. (default: `true`)
39
- - **loose** Allow the delimiter to be arbitrarily repeated, e.g. `/` or `///`. (default: `true`)
40
- - **delimiter** The default delimiter for segments, e.g. `[^/]` for `:named` parameters. (default: `'/'`)
41
- - **encodePath** A function for encoding input strings. (default: `x => x`, recommended: [`encodeurl`](https://github.com/pillarjs/encodeurl) for unicode encoding)
42
-
43
- ```js
44
- const regexp = pathToRegexp("/foo/:bar");
45
- // regexp = /^\/+foo(?:\/+([^\/]+?))(?:\/+)?$/i
46
- // keys = [{ name: 'bar', prefix: '', suffix: '', pattern: '', modifier: '' }]
47
- ```
48
-
49
- **Please note:** The `RegExp` returned by `path-to-regexp` is intended for ordered data (e.g. pathnames, hostnames). It can not handle arbitrarily ordered data (e.g. query strings, URL fragments, JSON, etc).
50
-
51
27
  ### Parameters
52
28
 
53
- The path argument is used to define parameters and populate keys.
54
-
55
- #### Named parameters
56
-
57
- Named parameters are defined by prefixing a colon to the parameter name (`:foo`). Parameter names can use any valid unicode identifier characters (similar to JavaScript).
58
-
59
- ```js
60
- const regexp = pathToRegexp("/:foo/:bar");
61
- // keys = [{ name: 'foo', ... }, { name: 'bar', ... }]
62
-
63
- regexp.exec("/test/route");
64
- //=> [ '/test/route', 'test', 'route', index: 0 ]
65
- ```
66
-
67
- ##### Custom matching parameters
68
-
69
- Parameters can have a custom regexp, which overrides the default match (`[^/]+`). For example, you can match digits or names in a path:
29
+ Parameters match arbitrary strings in a path by matching up to the end of the segment, or up to any proceeding tokens. They are defined by prefixing a colon to the parameter name (`:foo`). Parameter names can use any valid JavaScript identifier, or be double quoted to use other characters (`:"param-name"`).
70
30
 
71
31
  ```js
72
- const regexpNumbers = pathToRegexp("/icon-:foo(\\d+).png");
73
- // keys = [{ name: 'foo', ... }]
74
-
75
- regexpNumbers.exec("/icon-123.png");
76
- //=> ['/icon-123.png', '123']
77
-
78
- regexpNumbers.exec("/icon-abc.png");
79
- //=> null
32
+ const fn = match("/:foo/:bar");
80
33
 
81
- const regexpWord = pathToRegexp("/(user|u)");
82
- // keys = [{ name: 0, ... }]
83
-
84
- regexpWord.exec("/u");
85
- //=> ['/u', 'u']
86
-
87
- regexpWord.exec("/users");
88
- //=> null
34
+ fn("/test/route");
35
+ //=> { path: '/test/route', params: { foo: 'test', bar: 'route' } }
89
36
  ```
90
37
 
91
- **Tip:** Backslashes need to be escaped with another backslash in JavaScript strings.
92
-
93
- #### Unnamed parameters
38
+ ### Wildcard
94
39
 
95
- It is possible to define a parameter without a name. The name will be numerically indexed:
40
+ Wildcard parameters match one or more characters across multiple segments. They are defined the same way as regular parameters, but are prefixed with an asterisk (`*foo`).
96
41
 
97
42
  ```js
98
- const regexp = pathToRegexp("/:foo/(.*)");
99
- // keys = [{ name: 'foo', ... }, { name: '0', ... }]
43
+ const fn = match("/*splat");
100
44
 
101
- regexp.exec("/test/route");
102
- //=> [ '/test/route', 'test', 'route', index: 0 ]
45
+ fn("/bar/baz");
46
+ //=> { path: '/bar/baz', params: { splat: [ 'bar', 'baz' ] } }
103
47
  ```
104
48
 
105
- ##### Custom prefix and suffix
49
+ ### Optional
106
50
 
107
- Parameters can be wrapped in `{}` to create custom prefixes or suffixes for your segment:
51
+ Braces can be used to define parts of the path that are optional.
108
52
 
109
53
  ```js
110
- const regexp = pathToRegexp("{/:attr1}?{-:attr2}?{-:attr3}?");
54
+ const fn = match("/users{/:id}/delete");
111
55
 
112
- regexp.exec("/test");
113
- // => ['/test', 'test', undefined, undefined]
56
+ fn("/users/delete");
57
+ //=> { path: '/users/delete', params: {} }
114
58
 
115
- regexp.exec("/test-test");
116
- // => ['/test', 'test', 'test', undefined]
59
+ fn("/users/123/delete");
60
+ //=> { path: '/users/123/delete', params: { id: '123' } }
117
61
  ```
118
62
 
119
- #### Modifiers
120
-
121
- Modifiers are used after parameters with custom prefixes and suffixes (`{}`).
122
-
123
- ##### Optional
124
-
125
- Parameters can be suffixed with a question mark (`?`) to make the parameter optional.
126
-
127
- ```js
128
- const regexp = pathToRegexp("/:foo{/:bar}?");
129
- // keys = [{ name: 'foo', ... }, { name: 'bar', prefix: '/', modifier: '?' }]
130
-
131
- regexp.exec("/test");
132
- //=> [ '/test', 'test', undefined, index: 0 ]
133
-
134
- regexp.exec("/test/route");
135
- //=> [ '/test/route', 'test', 'route', index: 0 ]
136
- ```
137
-
138
- ##### Zero or more
139
-
140
- Parameters can be suffixed with an asterisk (`*`) to denote a zero or more parameter matches.
141
-
142
- ```js
143
- const regexp = pathToRegexp("{/:foo}*");
144
- // keys = [{ name: 'foo', prefix: '/', modifier: '*' }]
145
-
146
- regexp.exec("/foo");
147
- //=> [ '/foo', "foo", index: 0 ]
148
-
149
- regexp.exec("/bar/baz");
150
- //=> [ '/bar/baz', 'bar/baz', index: 0 ]
151
- ```
63
+ ## Match
152
64
 
153
- ##### One or more
65
+ The `match` function returns a function for matching strings against a path:
154
66
 
155
- Parameters can be suffixed with a plus sign (`+`) to denote a one or more parameter matches.
156
-
157
- ```js
158
- const regexp = pathToRegexp("{/:foo}+");
159
- // keys = [{ name: 'foo', prefix: '/', modifier: '+' }]
160
-
161
- regexp.exec("/");
162
- //=> null
163
-
164
- regexp.exec("/bar/baz");
165
- //=> [ '/bar/baz', 'bar/baz', index: 0 ]
166
- ```
167
-
168
- ##### Custom separator
169
-
170
- By default, parameters set the separator as the `prefix + suffix` of the token. Using `;` you can modify this:
171
-
172
- ```js
173
- const regexp = pathToRegexp("/name{/:parts;-}+");
174
-
175
- regexp.exec("/name");
176
- //=> null
177
-
178
- regexp.exec("/bar/1-2-3");
179
- //=> [ '/name/1-2-3', '1-2-3', index: 0 ]
180
- ```
181
-
182
- #### Wildcard
183
-
184
- A wildcard can also be used. It is roughly equivalent to `(.*)`.
185
-
186
- ```js
187
- const regexp = pathToRegexp("/*");
188
- // keys = [{ name: '0', pattern: '[^\\/]*', separator: '/', modifier: '*' }]
189
-
190
- regexp.exec("/");
191
- //=> [ '/', '', index: 0 ]
192
-
193
- regexp.exec("/bar/baz");
194
- //=> [ '/bar/baz', 'bar/baz', index: 0 ]
195
- ```
196
-
197
- ### Match
198
-
199
- The `match` function returns a function for transforming paths into parameters:
200
-
201
- - **path** A string.
202
- - **options** _(optional)_ The same options as `pathToRegexp`, plus:
203
- - **decode** Function for decoding strings for params, or `false` to disable entirely. (default: `decodeURIComponent`)
67
+ - **path** String or array of strings.
68
+ - **options** _(optional)_ (See [parse](#parse) for more options)
69
+ - **sensitive** Regexp will be case sensitive. (default: `false`)
70
+ - **end** Validate the match reaches the end of the string. (default: `true`)
71
+ - **trailing** Allows optional trailing delimiter to match. (default: `true`)
72
+ - **decode** Function for decoding strings to params, or `false` to disable all processing. (default: `decodeURIComponent`)
204
73
 
205
74
  ```js
206
- const fn = match("/user/:id");
207
-
208
- fn("/user/123"); //=> { path: '/user/123', index: 0, params: { id: '123' } }
209
- fn("/invalid"); //=> false
210
- fn("/user/caf%C3%A9"); //=> { path: '/user/caf%C3%A9', index: 0, params: { id: 'café' } }
75
+ const fn = match("/foo/:bar");
211
76
  ```
212
77
 
213
- **Note:** Setting `decode: false` disables the "splitting" behavior of repeated parameters, which is useful if you need the exactly matched parameter back.
78
+ **Please note:** `path-to-regexp` is intended for ordered data (e.g. pathnames, hostnames). It can not handle arbitrarily ordered data (e.g. query strings, URL fragments, JSON, etc).
214
79
 
215
- ### Compile ("Reverse" Path-To-RegExp)
80
+ ## Compile ("Reverse" Path-To-RegExp)
216
81
 
217
82
  The `compile` function will return a function for transforming parameters into a valid path:
218
83
 
219
84
  - **path** A string.
220
- - **options** _(optional)_ Similar to `pathToRegexp` (`delimiter`, `encodePath`, `sensitive`, and `loose`), plus:
221
- - **validate** When `false` the function can produce an invalid (unmatched) path. (default: `true`)
85
+ - **options** (See [parse](#parse) for more options)
222
86
  - **encode** Function for encoding input strings for output into the path, or `false` to disable entirely. (default: `encodeURIComponent`)
223
87
 
224
88
  ```js
@@ -227,53 +91,47 @@ const toPath = compile("/user/:id");
227
91
  toPath({ id: "name" }); //=> "/user/name"
228
92
  toPath({ id: "café" }); //=> "/user/caf%C3%A9"
229
93
 
230
- // When disabling `encode`, you need to make sure inputs are encoded correctly. No arrays are accepted.
231
- const toPathRaw = compile("/user/:id", { encode: false });
232
-
233
- toPathRaw({ id: "%3A%2F" }); //=> "/user/%3A%2F"
234
- toPathRaw({ id: ":/" }); //=> Throws, "/user/:/" when `validate` is `false`.
235
-
236
- const toPathRepeated = compile("{/:segment}+");
94
+ const toPathRepeated = compile("/*segment");
237
95
 
238
96
  toPathRepeated({ segment: ["foo"] }); //=> "/foo"
239
97
  toPathRepeated({ segment: ["a", "b", "c"] }); //=> "/a/b/c"
240
98
 
241
- const toPathRegexp = compile("/user/:id(\\d+)");
99
+ // When disabling `encode`, you need to make sure inputs are encoded correctly. No arrays are accepted.
100
+ const toPathRaw = compile("/user/:id", { encode: false });
242
101
 
243
- toPathRegexp({ id: "123" }); //=> "/user/123"
102
+ toPathRaw({ id: "%3A%2F" }); //=> "/user/%3A%2F"
244
103
  ```
245
104
 
246
105
  ## Developers
247
106
 
248
- - If you are rewriting paths with match and compiler, consider using `encode: false` and `decode: false` to keep raw paths passed around.
249
- - To ensure matches work on paths containing characters usually encoded, consider using [encodeurl](https://github.com/pillarjs/encodeurl) for `encodePath`.
250
- - If matches are intended to be exact, you need to set `loose: false`, `trailing: false`, and `sensitive: true`.
251
- - Enable `strict: true` to detect ReDOS issues.
107
+ - If you are rewriting paths with match and compile, consider using `encode: false` and `decode: false` to keep raw paths passed around.
108
+ - To ensure matches work on paths containing characters usually encoded, such as emoji, consider using [encodeurl](https://github.com/pillarjs/encodeurl) for `encodePath`.
252
109
 
253
110
  ### Parse
254
111
 
255
- A `parse` function is available and returns `TokenData`, the set of tokens and other metadata parsed from the input string. `TokenData` is can passed directly into `pathToRegexp`, `match`, and `compile`. It accepts only two options, `delimiter` and `encodePath`, which makes those options redundant in the above methods.
112
+ The `parse` function accepts a string and returns `TokenData`, the set of tokens and other metadata parsed from the input string. `TokenData` is can used with `match` and `compile`.
256
113
 
257
- ### Tokens
114
+ - **path** A string.
115
+ - **options** _(optional)_
116
+ - **delimiter** The default delimiter for segments, e.g. `[^/]` for `:named` parameters. (default: `'/'`)
117
+ - **encodePath** A function for encoding input strings. (default: `x => x`, recommended: [`encodeurl`](https://github.com/pillarjs/encodeurl))
258
118
 
259
- The `tokens` returned by `TokenData` is an array of strings or keys, represented as objects, with the following properties:
119
+ ### Tokens
260
120
 
261
- - `name` The name of the token
262
- - `prefix` _(optional)_ The prefix string for the segment (e.g. `"/"`)
263
- - `suffix` _(optional)_ The suffix string for the segment (e.g. `""`)
264
- - `pattern` _(optional)_ The pattern defined to match this token
265
- - `modifier` _(optional)_ The modifier character used for the segment (e.g. `?`)
266
- - `separator` _(optional)_ The string used to separate repeated parameters
121
+ `TokenData` is a sequence of tokens, currently of types `text`, `parameter`, `wildcard`, or `group`.
267
122
 
268
123
  ### Custom path
269
124
 
270
- In some applications, you may not be able to use the `path-to-regexp` syntax (e.g. file-based routing), but you can still use this library for `match`, `compile`, and `pathToRegexp` by building your own `TokenData` instance. For example:
125
+ In some applications, you may not be able to use the `path-to-regexp` syntax, but still want to use this library for `match` and `compile`. For example:
271
126
 
272
127
  ```js
273
128
  import { TokenData, match } from "path-to-regexp";
274
129
 
275
- const tokens = ["/", { name: "foo" }];
276
- const path = new TokenData(tokens, "/");
130
+ const tokens = [
131
+ { type: "text", value: "/" },
132
+ { type: "parameter", name: "foo" },
133
+ ];
134
+ const path = new TokenData(tokens);
277
135
  const fn = match(path);
278
136
 
279
137
  fn("/test"); //=> { path: '/test', index: 0, params: { foo: 'test' } }
@@ -283,31 +141,34 @@ fn("/test"); //=> { path: '/test', index: 0, params: { foo: 'test' } }
283
141
 
284
142
  An effort has been made to ensure ambiguous paths from previous releases throw an error. This means you might be seeing an error when things worked before.
285
143
 
286
- ### Unexpected `?`, `*`, or `+`
144
+ ### Unexpected `?` or `+`
145
+
146
+ In past releases, `?`, `*`, and `+` were used to denote optional or repeating parameters. As an alternative, try these:
147
+
148
+ - For optional (`?`), use an empty segment in a group such as `/:file{.:ext}`.
149
+ - For repeating (`+`), only wildcard matching is supported, such as `/*path`.
150
+ - For optional repeating (`*`), use a group and a wildcard parameter such as `/files{/*path}`.
287
151
 
288
- In previous major versions `/` and `.` were used as implicit prefixes of parameters. So `/:key?` was implicitly `{/:key}?`. For example:
152
+ ### Unexpected `(`, `)`, `[`, `]`, etc.
289
153
 
290
- - `/:key?` `{/:key}?` or `/:key*` `{/:key}*` or `/:key+` `{/:key}+`
291
- - `.:key?` → `{.:key}?` or `.:key*` → `{.:key}*` or `.:key+` → `{.:key}+`
292
- - `:key?` → `{:key}?` or `:key*` → `{:key}*` or `:key+` → `{:key}+`
154
+ Previous versions of Path-to-RegExp used these for RegExp features. This version no longer supports them so they've been reserved to avoid ambiguity. To use these characters literally, escape them with a backslash, e.g. `"\\("`.
293
155
 
294
- ### Unexpected `;`
156
+ ### Missing parameter name
295
157
 
296
- Used as a [custom separator](#custom-separator) for repeated parameters.
158
+ Parameter names, the part after `:` or `*`, must be a valid JavaScript identifier. For example, it cannot start with a number or contain a dash. If you want a parameter name that uses these characters you can wrap the name in quotes, e.g. `:"my-name"`.
297
159
 
298
- ### Unexpected `!`, `@`, or `,`
160
+ ### Unterminated quote
299
161
 
300
- These characters have been reserved for future use.
162
+ Parameter names can be wrapped in double quote characters, and this error means you forgot to close the quote character.
301
163
 
302
164
  ### Express <= 4.x
303
165
 
304
166
  Path-To-RegExp breaks compatibility with Express <= `4.x` in the following ways:
305
167
 
306
- - The only part of the string that is a regex is within `()`.
307
- - In Express.js 4.x, everything was passed as-is after a simple replacement, so you could write `/[a-z]+` to match `/test`.
308
- - The `?` optional character must be used after `{}`.
168
+ - Regexp characters can no longer be provided.
169
+ - The optional character `?` is no longer supported, use braces instead: `/:file{.:ext}`.
309
170
  - Some characters have new meaning or have been reserved (`{}?*+@!;`).
310
- - The parameter name now supports all unicode identifier characters, previously it was only `[a-z0-9]`.
171
+ - The parameter name now supports all JavaScript identifier characters, previously it was only `[a-z0-9]`.
311
172
 
312
173
  ## License
313
174
 
package/dist/index.d.ts CHANGED
@@ -7,76 +7,81 @@ export type Encode = (value: string) => string;
7
7
  */
8
8
  export type Decode = (value: string) => string;
9
9
  export interface ParseOptions {
10
- /**
11
- * The default delimiter for segments. (default: `'/'`)
12
- */
13
- delimiter?: string;
14
10
  /**
15
11
  * A function for encoding input strings.
16
12
  */
17
13
  encodePath?: Encode;
18
14
  }
19
- export interface PathToRegexpOptions extends ParseOptions {
15
+ export interface MatchOptions {
20
16
  /**
21
- * Regexp will be case sensitive. (default: `false`)
22
- */
23
- sensitive?: boolean;
24
- /**
25
- * Allow the delimiter to be arbitrarily repeated. (default: `true`)
26
- */
27
- loose?: boolean;
28
- /**
29
- * Verify patterns are valid and safe to use. (default: `false`)
30
- */
31
- strict?: boolean;
32
- /**
33
- * Match from the beginning of the string. (default: `true`)
17
+ * Function for decoding strings for params, or `false` to disable entirely. (default: `decodeURIComponent`)
34
18
  */
35
- start?: boolean;
19
+ decode?: Decode | false;
36
20
  /**
37
- * Match to the end of the string. (default: `true`)
21
+ * Matches the path completely without trailing characters. (default: `true`)
38
22
  */
39
23
  end?: boolean;
40
24
  /**
41
- * Allow optional trailing delimiter to match. (default: `true`)
25
+ * Allows optional trailing delimiter to match. (default: `true`)
42
26
  */
43
27
  trailing?: boolean;
44
- }
45
- export interface MatchOptions extends PathToRegexpOptions {
46
28
  /**
47
- * Function for decoding strings for params, or `false` to disable entirely. (default: `decodeURIComponent`)
48
- */
49
- decode?: Decode | false;
50
- }
51
- export interface CompileOptions extends ParseOptions {
52
- /**
53
- * Regexp will be case sensitive. (default: `false`)
29
+ * Match will be case sensitive. (default: `false`)
54
30
  */
55
31
  sensitive?: boolean;
56
32
  /**
57
- * Allow the delimiter to be arbitrarily repeated. (default: `true`)
58
- */
59
- loose?: boolean;
60
- /**
61
- * Verify patterns are valid and safe to use. (default: `false`)
62
- */
63
- strict?: boolean;
64
- /**
65
- * Verifies the function is producing a valid path. (default: `true`)
33
+ * The default delimiter for segments. (default: `'/'`)
66
34
  */
67
- validate?: boolean;
35
+ delimiter?: string;
36
+ }
37
+ export interface CompileOptions {
68
38
  /**
69
39
  * Function for encoding input strings for output into the path, or `false` to disable entirely. (default: `encodeURIComponent`)
70
40
  */
71
41
  encode?: Encode | false;
42
+ /**
43
+ * The default delimiter for segments. (default: `'/'`)
44
+ */
45
+ delimiter?: string;
46
+ }
47
+ /**
48
+ * Plain text.
49
+ */
50
+ export interface Text {
51
+ type: "text";
52
+ value: string;
53
+ }
54
+ /**
55
+ * A parameter designed to match arbitrary text within a segment.
56
+ */
57
+ export interface Parameter {
58
+ type: "param";
59
+ name: string;
60
+ }
61
+ /**
62
+ * A wildcard parameter designed to match multiple segments.
63
+ */
64
+ export interface Wildcard {
65
+ type: "wildcard";
66
+ name: string;
67
+ }
68
+ /**
69
+ * A set of possible tokens to expand when matching.
70
+ */
71
+ export interface Group {
72
+ type: "group";
73
+ tokens: Token[];
72
74
  }
73
75
  /**
74
- * Tokenized path instance. Can we passed around instead of string.
76
+ * A sequence of path match characters.
77
+ */
78
+ export type Token = Text | Parameter | Wildcard | Group;
79
+ /**
80
+ * Tokenized path instance.
75
81
  */
76
82
  export declare class TokenData {
77
83
  readonly tokens: Token[];
78
- readonly delimiter: string;
79
- constructor(tokens: Token[], delimiter: string);
84
+ constructor(tokens: Token[]);
80
85
  }
81
86
  /**
82
87
  * Parse a string for the raw tokens.
@@ -85,7 +90,7 @@ export declare function parse(str: string, options?: ParseOptions): TokenData;
85
90
  /**
86
91
  * Compile a string to a template function for the path.
87
92
  */
88
- export declare function compile<P extends ParamData = ParamData>(path: Path, options?: CompileOptions): PathFunction<P>;
93
+ export declare function compile<P extends ParamData = ParamData>(path: Path, options?: CompileOptions & ParseOptions): PathFunction<P>;
89
94
  export type ParamData = Partial<Record<string, string | string[]>>;
90
95
  export type PathFunction<P extends ParamData> = (data?: P) => string;
91
96
  /**
@@ -93,7 +98,6 @@ export type PathFunction<P extends ParamData> = (data?: P) => string;
93
98
  */
94
99
  export interface MatchResult<P extends ParamData> {
95
100
  path: string;
96
- index: number;
97
101
  params: P;
98
102
  }
99
103
  /**
@@ -104,36 +108,5 @@ export type Match<P extends ParamData> = false | MatchResult<P>;
104
108
  * The match function takes a string and returns whether it matched the path.
105
109
  */
106
110
  export type MatchFunction<P extends ParamData> = (path: string) => Match<P>;
107
- /**
108
- * Create path match function from `path-to-regexp` spec.
109
- */
110
- export declare function match<P extends ParamData>(path: Path, options?: MatchOptions): MatchFunction<P>;
111
- /**
112
- * A key is a capture group in the regex.
113
- */
114
- export interface Key {
115
- name: string;
116
- prefix?: string;
117
- suffix?: string;
118
- pattern?: string;
119
- modifier?: string;
120
- separator?: string;
121
- }
122
- /**
123
- * A token is a string (nothing special) or key metadata (capture group).
124
- */
125
- export type Token = string | Key;
126
- /**
127
- * Repeated and simple input types.
128
- */
129
111
  export type Path = string | TokenData;
130
- /**
131
- * Normalize the given path string, returning a regular expression.
132
- *
133
- * An empty array can be passed in for the keys, which will hold the
134
- * placeholder key descriptions. For example, using `/user/:id`, `keys` will
135
- * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
136
- */
137
- export declare function pathToRegexp(path: Path, options?: PathToRegexpOptions): RegExp & {
138
- keys: Key[];
139
- };
112
+ export declare function match<P extends ParamData>(path: Path | Path[], options?: MatchOptions & ParseOptions): MatchFunction<P>;