This commit is contained in:
2026-07-26 21:23:30 +00:00
parent 6fa0e1b9a6
commit 7c262aeb8b
60 changed files with 2359 additions and 582 deletions
+3 -3
View File
@@ -153,7 +153,7 @@ The `parse` function accepts a string and returns `TokenData`, which can be used
`TokenData` has two properties:
- **tokens** A sequence of tokens, currently of types `text`, `parameter`, `wildcard`, or `group`.
- **tokens** A sequence of tokens, currently of types `text`, `param`, `wildcard`, or `group`.
- **originalPath** The original path used with `parse`, shown in error messages to assist debugging.
### Custom path
@@ -165,13 +165,13 @@ import { match } from "path-to-regexp";
const tokens = [
{ type: "text", value: "/" },
{ type: "parameter", name: "foo" },
{ type: "param", name: "foo" },
];
const originalPath = "/[foo]"; // To help debug error messages.
const path = { tokens, originalPath };
const fn = match(path);
fn("/test"); //=> { path: '/test', index: 0, params: { foo: 'test' } }
fn("/test"); //=> { path: '/test', params: { foo: 'test' } }
```
## Errors