File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 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
1717## Usage
1818
1919``` 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" );
2127```
2228
2329### Parameters
@@ -111,6 +117,21 @@ const toPathRaw = compile("/user/:id", { encode: false });
111117toPathRaw ({ id: " %3A%2F" }); // => "/user/%3A%2F"
112118```
113119
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+
114135## Developers
115136
116137- 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