You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**decode** Function for decoding strings to params, or `false` to disable all processing. (default: `decodeURIComponent`)
72
72
@@ -80,7 +80,7 @@ const fn = match("/foo/:bar");
80
80
81
81
The `pathToRegexp` function returns the `regexp` for matching strings against paths, and an array of `keys` for understanding the `RegExp#exec` matches.
82
82
83
-
-**path** Stringor array of strings.
83
+
-**path** String, `TokenData` object, or array of strings and `TokenData` objects.
84
84
-**options**_(optional)_ (See [parse](#parse) for more options)
85
85
-**sensitive** Regexp will be case sensitive. (default: `false`)
86
86
-**end** Validate the match reaches the end of the string. (default: `true`)
Transform `TokenData`(a sequence of tokens) back into a Path-to-RegExp string.
124
+
Transform a `TokenData`object to a Path-to-RegExp string.
125
125
126
-
-**data** A `TokenData`instance
126
+
-**data** A `TokenData`object.
127
127
128
128
```js
129
-
constdata=newTokenData([
130
-
{ type:"text", value:"/" },
131
-
{ type:"param", name:"foo" },
132
-
]);
129
+
constdata= {
130
+
tokens: [
131
+
{ type:"text", value:"/" },
132
+
{ type:"param", name:"foo" },
133
+
],
134
+
};
133
135
134
136
constpath=stringify(data); //=> "/:foo"
135
137
```
@@ -149,20 +151,24 @@ The `parse` function accepts a string and returns `TokenData`, which can be used
149
151
150
152
### Tokens
151
153
152
-
`TokenData` is a sequence of tokens, currently of types `text`, `parameter`, `wildcard`, or `group`.
154
+
`TokenData` has two properties:
155
+
156
+
-**tokens** A sequence of tokens, currently of types `text`, `parameter`, `wildcard`, or `group`.
157
+
-**originalPath** The original path used with `parse`, shown in error messages to assist debugging.
153
158
154
159
### Custom path
155
160
156
-
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:
161
+
In some applications you may not be able to use the `path-to-regexp` syntax, but you still want to use this library for `match` and `compile`. For example:
157
162
158
163
```js
159
-
import { TokenData, match } from"path-to-regexp";
164
+
import { match } from"path-to-regexp";
160
165
161
166
consttokens= [
162
167
{ type:"text", value:"/" },
163
168
{ type:"parameter", name:"foo" },
164
169
];
165
-
constpath=newTokenData(tokens);
170
+
constoriginalPath="/[foo]"; // To help debug error messages.
0 commit comments