File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,13 @@ npm install path-to-regexp --save
17
17
## Usage
18
18
19
19
``` js
20
- const { match , pathToRegexp , compile , parse } = require (" path-to-regexp" );
20
+ const {
21
+ match ,
22
+ pathToRegexp ,
23
+ compile ,
24
+ parse ,
25
+ stringify ,
26
+ } = require (" path-to-regexp" );
21
27
```
22
28
23
29
### Parameters
@@ -111,6 +117,21 @@ const toPathRaw = compile("/user/:id", { encode: false });
111
117
toPathRaw ({ id: " %3A%2F" }); // => "/user/%3A%2F"
112
118
```
113
119
120
+ ## Stringify
121
+
122
+ Transform ` TokenData ` (a sequence of tokens) back into a Path-to-RegExp string.
123
+
124
+ - ** data** A ` TokenData ` instance
125
+
126
+ ``` js
127
+ const data = new TokenData ([
128
+ { type: " text" , value: " /" },
129
+ { type: " param" , name: " foo" },
130
+ ]);
131
+
132
+ const path = stringify (data); // => "/:foo"
133
+ ```
134
+
114
135
## Developers
115
136
116
137
- If you are rewriting paths with match and compile, consider using ` encode: false ` and ` decode: false ` to keep raw paths passed around.
You can’t perform that action at this time.
0 commit comments