path-to-regexp 7.0.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,263 +17,158 @@ 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** Regexp allows an optional trailing delimiter to match. (default: `true`)
36
- - **end** Match to the end of the string. (default: `true`)
37
- - **start** Match from the beginning of the string. (default: `true`)
38
- - **loose** Allow the delimiter to be repeated an arbitrary number of times. (default: `true`)
39
- - **delimiter** The default delimiter for segments, e.g. `[^/]` for `:named` parameters. (default: `'/'`)
40
- - **encodePath** A function to encode strings before inserting into `RegExp`. (default: `x => x`, recommended: [`encodeurl`](https://github.com/pillarjs/encodeurl))
41
-
42
- ```js
43
- const regexp = pathToRegexp("/foo/:bar");
44
- // regexp = /^\/+foo(?:\/+([^\/]+?))(?:\/+)?$/i
45
- // keys = [{ name: 'bar', prefix: '', suffix: '', pattern: '', modifier: '' }]
46
- ```
47
-
48
- **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).
49
-
50
27
  ### Parameters
51
28
 
52
- The path argument is used to define parameters and populate keys.
53
-
54
- #### Named parameters
55
-
56
- 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).
57
-
58
- ```js
59
- const regexp = pathToRegexp("/:foo/:bar");
60
- // keys = [{ name: 'foo', ... }, { name: 'bar', ... }]
61
-
62
- regexp.exec("/test/route");
63
- //=> [ '/test/route', 'test', 'route', index: 0 ]
64
- ```
65
-
66
- ##### Custom matching parameters
67
-
68
- 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"`).
69
30
 
70
31
  ```js
71
- const regexpNumbers = pathToRegexp("/icon-:foo(\\d+).png");
72
- // keys = [{ name: 'foo', ... }]
73
-
74
- regexpNumbers.exec("/icon-123.png");
75
- //=> ['/icon-123.png', '123']
76
-
77
- regexpNumbers.exec("/icon-abc.png");
78
- //=> null
79
-
80
- const regexpWord = pathToRegexp("/(user|u)");
81
- // keys = [{ name: 0, ... }]
82
-
83
- regexpWord.exec("/u");
84
- //=> ['/u', 'u']
32
+ const fn = match("/:foo/:bar");
85
33
 
86
- regexpWord.exec("/users");
87
- //=> null
34
+ fn("/test/route");
35
+ //=> { path: '/test/route', params: { foo: 'test', bar: 'route' } }
88
36
  ```
89
37
 
90
- **Tip:** Backslashes need to be escaped with another backslash in JavaScript strings.
38
+ ### Wildcard
91
39
 
92
- #### Unnamed parameters
93
-
94
- 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`).
95
41
 
96
42
  ```js
97
- const regexp = pathToRegexp("/:foo/(.*)");
98
- // keys = [{ name: 'foo', ... }, { name: '0', ... }]
43
+ const fn = match("/*splat");
99
44
 
100
- regexp.exec("/test/route");
101
- //=> [ '/test/route', 'test', 'route', index: 0 ]
45
+ fn("/bar/baz");
46
+ //=> { path: '/bar/baz', params: { splat: [ 'bar', 'baz' ] } }
102
47
  ```
103
48
 
104
- ##### Custom prefix and suffix
49
+ ### Optional
105
50
 
106
- 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.
107
52
 
108
53
  ```js
109
- const regexp = pathToRegexp("{/:attr1}?{-:attr2}?{-:attr3}?");
54
+ const fn = match("/users{/:id}/delete");
110
55
 
111
- regexp.exec("/test");
112
- // => ['/test', 'test', undefined, undefined]
56
+ fn("/users/delete");
57
+ //=> { path: '/users/delete', params: {} }
113
58
 
114
- regexp.exec("/test-test");
115
- // => ['/test', 'test', 'test', undefined]
59
+ fn("/users/123/delete");
60
+ //=> { path: '/users/123/delete', params: { id: '123' } }
116
61
  ```
117
62
 
118
- #### Modifiers
119
-
120
- Modifiers are used after parameters with custom prefixes and suffixes (`{}`).
63
+ ## Match
121
64
 
122
- ##### Optional
65
+ The `match` function returns a function for matching strings against a path:
123
66
 
124
- Parameters can be suffixed with a question mark (`?`) to make the parameter optional.
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`)
125
73
 
126
74
  ```js
127
- const regexp = pathToRegexp("/:foo{/:bar}?");
128
- // keys = [{ name: 'foo', ... }, { name: 'bar', prefix: '/', modifier: '?' }]
129
-
130
- regexp.exec("/test");
131
- //=> [ '/test', 'test', undefined, index: 0 ]
132
-
133
- regexp.exec("/test/route");
134
- //=> [ '/test/route', 'test', 'route', index: 0 ]
75
+ const fn = match("/foo/:bar");
135
76
  ```
136
77
 
137
- ##### Zero or more
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).
138
79
 
139
- Parameters can be suffixed with an asterisk (`*`) to denote a zero or more parameter matches.
80
+ ## Compile ("Reverse" Path-To-RegExp)
140
81
 
141
- ```js
142
- const regexp = pathToRegexp("{/:foo}*");
143
- // keys = [{ name: 'foo', prefix: '/', modifier: '*' }]
144
-
145
- regexp.exec("/foo");
146
- //=> [ '/foo', "foo", index: 0 ]
147
-
148
- regexp.exec("/bar/baz");
149
- //=> [ '/bar/baz', 'bar/baz', index: 0 ]
150
- ```
151
-
152
- ##### One or more
82
+ The `compile` function will return a function for transforming parameters into a valid path:
153
83
 
154
- Parameters can be suffixed with a plus sign (`+`) to denote a one or more parameter matches.
84
+ - **path** A string.
85
+ - **options** (See [parse](#parse) for more options)
86
+ - **encode** Function for encoding input strings for output into the path, or `false` to disable entirely. (default: `encodeURIComponent`)
155
87
 
156
88
  ```js
157
- const regexp = pathToRegexp("{/:foo}+");
158
- // keys = [{ name: 'foo', prefix: '/', modifier: '+' }]
159
-
160
- regexp.exec("/");
161
- //=> null
162
-
163
- regexp.exec("/bar/baz");
164
- //=> [ '/bar/baz', 'bar/baz', index: 0 ]
165
- ```
89
+ const toPath = compile("/user/:id");
166
90
 
167
- #### Wildcard
91
+ toPath({ id: "name" }); //=> "/user/name"
92
+ toPath({ id: "café" }); //=> "/user/caf%C3%A9"
168
93
 
169
- A wildcard can also be used. It is roughly equivalent to `(.*)`.
94
+ const toPathRepeated = compile("/*segment");
170
95
 
171
- ```js
172
- const regexp = pathToRegexp("/*");
173
- // keys = [{ name: '0', pattern: '[^\\/]*', separator: '/', modifier: '*' }]
96
+ toPathRepeated({ segment: ["foo"] }); //=> "/foo"
97
+ toPathRepeated({ segment: ["a", "b", "c"] }); //=> "/a/b/c"
174
98
 
175
- regexp.exec("/");
176
- //=> [ '/', '', index: 0 ]
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 });
177
101
 
178
- regexp.exec("/bar/baz");
179
- //=> [ '/bar/baz', 'bar/baz', index: 0 ]
102
+ toPathRaw({ id: "%3A%2F" }); //=> "/user/%3A%2F"
180
103
  ```
181
104
 
182
- ### Match
183
-
184
- The `match` function returns a function for transforming paths into parameters:
185
-
186
- - **path** A string.
187
- - **options** _(optional)_ The same options as `pathToRegexp`, plus:
188
- - **decode** Function for decoding strings for params, or `false` to disable entirely. (default: `decodeURIComponent`)
189
-
190
- ```js
191
- // Make sure you consistently `decode` segments.
192
- const fn = match("/user/:id", { decode: decodeURIComponent });
193
-
194
- fn("/user/123"); //=> { path: '/user/123', index: 0, params: { id: '123' } }
195
- fn("/invalid"); //=> false
196
- fn("/user/caf%C3%A9"); //=> { path: '/user/caf%C3%A9', index: 0, params: { id: 'café' } }
197
- ```
105
+ ## Developers
198
106
 
199
- **Note:** Setting `decode: false` disables the "splitting" behavior of repeated parameters, which is useful if you need the exactly matched parameter back.
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`.
200
109
 
201
- ### Compile ("Reverse" Path-To-RegExp)
110
+ ### Parse
202
111
 
203
- The `compile` function will return a function for transforming parameters into a valid path:
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`.
204
113
 
205
114
  - **path** A string.
206
- - **options** _(optional)_ Similar to `pathToRegexp` (`delimiter`, `encodePath`, `sensitive`, and `loose`), plus:
207
- - **validate** When `false` the function can produce an invalid (unmatched) path. (default: `true`)
208
- - **encode** Function for encoding input strings for output into the path, or `false` to disable entirely. (default: `encodeURIComponent`)
209
-
210
- ```js
211
- const toPath = compile("/user/:id");
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))
212
118
 
213
- toPath({ id: 123 }); //=> "/user/123"
214
- toPath({ id: "café" }); //=> "/user/caf%C3%A9"
215
- toPath({ id: ":/" }); //=> "/user/%3A%2F"
119
+ ### Tokens
216
120
 
217
- // When disabling `encode`, you need to make sure inputs are encoded correctly. No arrays are accepted.
218
- const toPathRaw = compile("/user/:id", { encode: false });
121
+ `TokenData` is a sequence of tokens, currently of types `text`, `parameter`, `wildcard`, or `group`.
219
122
 
220
- toPathRaw({ id: "%3A%2F" }); //=> "/user/%3A%2F"
221
- toPathRaw({ id: ":/" }); //=> "/user/:/", throws when `validate: false` is not set.
123
+ ### Custom path
222
124
 
223
- const toPathRepeated = compile("{/:segment}+");
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:
224
126
 
225
- toPathRepeated({ segment: ["foo"] }); //=> "/foo"
226
- toPathRepeated({ segment: ["a", "b", "c"] }); //=> "/a/b/c"
127
+ ```js
128
+ import { TokenData, match } from "path-to-regexp";
227
129
 
228
- const toPathRegexp = compile("/user/:id(\\d+)");
130
+ const tokens = [
131
+ { type: "text", value: "/" },
132
+ { type: "parameter", name: "foo" },
133
+ ];
134
+ const path = new TokenData(tokens);
135
+ const fn = match(path);
229
136
 
230
- toPathRegexp({ id: "123" }); //=> "/user/123"
137
+ fn("/test"); //=> { path: '/test', index: 0, params: { foo: 'test' } }
231
138
  ```
232
139
 
233
- ## Developers
234
-
235
- - If you are rewriting paths with match and compiler, consider using `encode: false` and `decode: false` to keep raw paths passed around.
236
- - To ensure matches work on paths containing characters usually encoded, consider using [encodeurl](https://github.com/pillarjs/encodeurl) for `encodePath`.
237
- - If matches are intended to be exact, you need to set `loose: false`, `trailing: false`, and `sensitive: true`.
238
-
239
- ### Parse
140
+ ## Errors
240
141
 
241
- 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.
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.
242
143
 
243
- ### Token Information
144
+ ### Unexpected `?` or `+`
244
145
 
245
- - `name` The name of the token
246
- - `prefix` _(optional)_ The prefix string for the segment (e.g. `"/"`)
247
- - `suffix` _(optional)_ The suffix string for the segment (e.g. `""`)
248
- - `pattern` _(optional)_ The pattern defined to match this token
249
- - `modifier` _(optional)_ The modifier character used for the segment (e.g. `?`)
250
- - `separator` _(optional)_ The string used to separate repeated parameters
146
+ In past releases, `?`, `*`, and `+` were used to denote optional or repeating parameters. As an alternative, try these:
251
147
 
252
- ## Errors
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}`.
253
151
 
254
- 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.
152
+ ### Unexpected `(`, `)`, `[`, `]`, etc.
255
153
 
256
- ### Unexpected `?`, `*`, or `+`
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. `"\\("`.
257
155
 
258
- In previous major versions `/` and `.` were used as implicit prefixes of parameters. So `/:key?` was implicitly `{/:key}?`. For example:
156
+ ### Missing parameter name
259
157
 
260
- - `/:key?` `{/:key}?` or `/:key*` `{/:key}*` or `/:key+` `{/:key}+`
261
- - `.:key?` → `{.:key}?` or `.:key*` → `{.:key}*` or `.:key+` → `{.:key}+`
262
- - `:key?` → `{:key}?` or `:key*` → `{:key}*` or `:key+` → `{:key}+`
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"`.
263
159
 
264
- ### Unexpected `!`, `@`, `,`, or `;`
160
+ ### Unterminated quote
265
161
 
266
- 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.
267
163
 
268
164
  ### Express <= 4.x
269
165
 
270
166
  Path-To-RegExp breaks compatibility with Express <= `4.x` in the following ways:
271
167
 
272
- - The only part of the string that is a regex is within `()`.
273
- - In Express.js 4.x, everything was passed as-is after a simple replacement, so you could write `/[a-z]+` to match `/test`.
274
- - 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}`.
275
170
  - Some characters have new meaning or have been reserved (`{}?*+@!;`).
276
- - 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]`.
277
172
 
278
173
  ## License
279
174
 
package/dist/index.d.ts CHANGED
@@ -8,67 +8,80 @@ export type Encode = (value: string) => string;
8
8
  export type Decode = (value: string) => string;
9
9
  export interface ParseOptions {
10
10
  /**
11
- * Set the default delimiter for repeat parameters. (default: `'/'`)
12
- */
13
- delimiter?: string;
14
- /**
15
- * Function for encoding input strings for output into path.
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
- * When `true` the regexp will be case sensitive. (default: `false`)
22
- */
23
- sensitive?: boolean;
24
- /**
25
- * Allow delimiter to be arbitrarily repeated. (default: `true`)
17
+ * Function for decoding strings for params, or `false` to disable entirely. (default: `decodeURIComponent`)
26
18
  */
27
- loose?: boolean;
19
+ decode?: Decode | false;
28
20
  /**
29
- * When `true` the regexp will match to the end of the string. (default: `true`)
21
+ * Matches the path completely without trailing characters. (default: `true`)
30
22
  */
31
23
  end?: boolean;
32
24
  /**
33
- * When `true` the regexp will match from the beginning of the string. (default: `true`)
34
- */
35
- start?: boolean;
36
- /**
37
- * When `true` the regexp allows an optional trailing delimiter to match. (default: `true`)
25
+ * Allows optional trailing delimiter to match. (default: `true`)
38
26
  */
39
27
  trailing?: boolean;
40
- }
41
- export interface MatchOptions extends PathToRegexpOptions {
42
- /**
43
- * Function for decoding strings for params, or `false` to disable entirely. (default: `decodeURIComponent`)
44
- */
45
- decode?: Decode | false;
46
- }
47
- export interface CompileOptions extends ParseOptions {
48
28
  /**
49
- * When `true` the validation will be case sensitive. (default: `false`)
29
+ * Match will be case sensitive. (default: `false`)
50
30
  */
51
31
  sensitive?: boolean;
52
32
  /**
53
- * Allow delimiter to be arbitrarily repeated. (default: `true`)
33
+ * The default delimiter for segments. (default: `'/'`)
54
34
  */
55
- loose?: boolean;
56
- /**
57
- * When `false` the function can produce an invalid (unmatched) path. (default: `true`)
58
- */
59
- validate?: boolean;
35
+ delimiter?: string;
36
+ }
37
+ export interface CompileOptions {
60
38
  /**
61
39
  * Function for encoding input strings for output into the path, or `false` to disable entirely. (default: `encodeURIComponent`)
62
40
  */
63
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;
64
53
  }
65
54
  /**
66
- * Tokenized path instance. Can we passed around instead of string.
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[];
74
+ }
75
+ /**
76
+ * A sequence of path match characters.
77
+ */
78
+ export type Token = Text | Parameter | Wildcard | Group;
79
+ /**
80
+ * Tokenized path instance.
67
81
  */
68
82
  export declare class TokenData {
69
83
  readonly tokens: Token[];
70
- readonly delimiter: string;
71
- constructor(tokens: Token[], delimiter: string);
84
+ constructor(tokens: Token[]);
72
85
  }
73
86
  /**
74
87
  * Parse a string for the raw tokens.
@@ -77,7 +90,7 @@ export declare function parse(str: string, options?: ParseOptions): TokenData;
77
90
  /**
78
91
  * Compile a string to a template function for the path.
79
92
  */
80
- export declare function compile<P extends object = object>(path: Path, options?: CompileOptions): PathFunction<P>;
93
+ export declare function compile<P extends ParamData = ParamData>(path: Path, options?: CompileOptions & ParseOptions): PathFunction<P>;
81
94
  export type ParamData = Partial<Record<string, string | string[]>>;
82
95
  export type PathFunction<P extends ParamData> = (data?: P) => string;
83
96
  /**
@@ -85,7 +98,6 @@ export type PathFunction<P extends ParamData> = (data?: P) => string;
85
98
  */
86
99
  export interface MatchResult<P extends ParamData> {
87
100
  path: string;
88
- index: number;
89
101
  params: P;
90
102
  }
91
103
  /**
@@ -96,39 +108,5 @@ export type Match<P extends ParamData> = false | MatchResult<P>;
96
108
  * The match function takes a string and returns whether it matched the path.
97
109
  */
98
110
  export type MatchFunction<P extends ParamData> = (path: string) => Match<P>;
99
- /**
100
- * Create path match function from `path-to-regexp` spec.
101
- */
102
- export declare function match<P extends ParamData>(path: Path, options?: MatchOptions): MatchFunction<P>;
103
- /**
104
- * A key is a capture group in the regex.
105
- */
106
- export interface Key {
107
- name: string;
108
- prefix?: string;
109
- suffix?: string;
110
- pattern?: string;
111
- modifier?: string;
112
- separator?: string;
113
- }
114
- /**
115
- * A token is a string (nothing special) or key metadata (capture group).
116
- */
117
- export type Token = string | Key;
118
- /**
119
- * Repeated and simple input types.
120
- */
121
111
  export type Path = string | TokenData;
122
- export type PathRegExp = RegExp & {
123
- keys: Key[];
124
- };
125
- /**
126
- * Normalize the given path string, returning a regular expression.
127
- *
128
- * An empty array can be passed in for the keys, which will hold the
129
- * placeholder key descriptions. For example, using `/user/:id`, `keys` will
130
- * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
131
- */
132
- export declare function pathToRegexp(path: Path, options?: PathToRegexpOptions): RegExp & {
133
- keys: Key[];
134
- };
112
+ export declare function match<P extends ParamData>(path: Path | Path[], options?: MatchOptions & ParseOptions): MatchFunction<P>;