[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-10177":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},10177,"path-to-regexp","pillarjs\u002Fpath-to-regexp","pillarjs","Turn a path string such as `\u002Fuser\u002F:name` into a regular expression","",null,"TypeScript",8595,481,64,4,0,1,12,39.05,"MIT License",false,"master",[24,25,5,26],"expressjs","nodejs","router","2026-06-12 02:02:18","# Path-to-RegExp\n\n> Turn a path string such as `\u002Fuser\u002F:name` into a regular expression.\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][downloads-image]][downloads-url]\n[![Build status][build-image]][build-url]\n[![Build coverage][coverage-image]][coverage-url]\n[![License][license-image]][license-url]\n\n## Installation\n\n```\nnpm install path-to-regexp --save\n```\n\n## Usage\n\n```js\nconst {\n  match,\n  pathToRegexp,\n  compile,\n  parse,\n  stringify,\n} = require(\"path-to-regexp\");\n```\n\n### Parameters\n\nParameters 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\"`).\n\n```js\nconst fn = match(\"\u002F:foo\u002F:bar\");\n\nfn(\"\u002Ftest\u002Froute\");\n\u002F\u002F=> { path: '\u002Ftest\u002Froute', params: { foo: 'test', bar: 'route' } }\n```\n\n### Wildcard\n\nWildcard 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`).\n\n```js\nconst fn = match(\"\u002F*splat\");\n\nfn(\"\u002Fbar\u002Fbaz\");\n\u002F\u002F=> { path: '\u002Fbar\u002Fbaz', params: { splat: [ 'bar', 'baz' ] } }\n```\n\n### Optional\n\nBraces can be used to define parts of the path that are optional.\n\n```js\nconst fn = match(\"\u002Fusers{\u002F:id}\u002Fdelete\");\n\nfn(\"\u002Fusers\u002Fdelete\");\n\u002F\u002F=> { path: '\u002Fusers\u002Fdelete', params: {} }\n\nfn(\"\u002Fusers\u002F123\u002Fdelete\");\n\u002F\u002F=> { path: '\u002Fusers\u002F123\u002Fdelete', params: { id: '123' } }\n```\n\n## Match\n\nThe `match` function returns a function for matching strings against a path:\n\n- **path** String, `TokenData` object, or array of strings and `TokenData` objects.\n- **options** _(optional)_ (Extends [pathToRegexp](#pathToRegexp) options)\n  - **decode** Function for decoding strings to params, or `false` to disable all processing. (default: `decodeURIComponent`)\n\n```js\nconst fn = match(\"\u002Ffoo\u002F:bar\");\n```\n\n**Please note:** `path-to-regexp` is intended for ordered data (e.g. paths, hosts). It can not handle arbitrarily ordered data (e.g. query strings, URL fragments, JSON, etc).\n\n## PathToRegexp\n\nThe `pathToRegexp` function returns the `regexp` for matching strings against paths, and an array of `keys` for understanding the `RegExp#exec` matches.\n\n- **path** String, `TokenData` object, or array of strings and `TokenData` objects.\n- **options** _(optional)_ (See [parse](#parse) for more options)\n  - **sensitive** Regexp will be case sensitive. (default: `false`)\n  - **end** Validate the match reaches the end of the string. (default: `true`)\n  - **delimiter** The default delimiter for segments, e.g. `[^\u002F]` for `:named` parameters. (default: `'\u002F'`)\n  - **trailing** Allows optional trailing delimiter to match. (default: `true`)\n\n```js\nconst { regexp, keys } = pathToRegexp(\"\u002Ffoo\u002F:bar\");\n\nregexp.exec(\"\u002Ffoo\u002F123\"); \u002F\u002F=> [\"\u002Ffoo\u002F123\", \"123\"]\n```\n\n## Compile (\"Reverse\" Path-To-RegExp)\n\nThe `compile` function will return a function for transforming parameters into a valid path:\n\n- **path** A string or `TokenData` object.\n- **options** (See [parse](#parse) for more options)\n  - **delimiter** The default delimiter for segments, e.g. `[^\u002F]` for `:named` parameters. (default: `'\u002F'`)\n  - **encode** Function for encoding input strings for output into the path, or `false` to disable entirely. (default: `encodeURIComponent`)\n\n```js\nconst toPath = compile(\"\u002Fuser\u002F:id\");\n\ntoPath({ id: \"name\" }); \u002F\u002F=> \"\u002Fuser\u002Fname\"\ntoPath({ id: \"café\" }); \u002F\u002F=> \"\u002Fuser\u002Fcaf%C3%A9\"\n\nconst toPathRepeated = compile(\"\u002F*segment\");\n\ntoPathRepeated({ segment: [\"foo\"] }); \u002F\u002F=> \"\u002Ffoo\"\ntoPathRepeated({ segment: [\"a\", \"b\", \"c\"] }); \u002F\u002F=> \"\u002Fa\u002Fb\u002Fc\"\n\n\u002F\u002F When disabling `encode`, you need to make sure inputs are encoded correctly. No arrays are accepted.\nconst toPathRaw = compile(\"\u002Fuser\u002F:id\", { encode: false });\n\ntoPathRaw({ id: \"%3A%2F\" }); \u002F\u002F=> \"\u002Fuser\u002F%3A%2F\"\n```\n\n## Stringify\n\nTransform a `TokenData` object to a Path-to-RegExp string.\n\n- **data** A `TokenData` object.\n\n```js\nconst data = {\n  tokens: [\n    { type: \"text\", value: \"\u002F\" },\n    { type: \"param\", name: \"foo\" },\n  ],\n};\n\nconst path = stringify(data); \u002F\u002F=> \"\u002F:foo\"\n```\n\n## Developers\n\n- If you are rewriting paths with match and compile, consider using `encode: false` and `decode: false` to keep raw paths passed around.\n- To ensure matches work on paths containing characters usually encoded, such as emoji, consider using [encodeurl](https:\u002F\u002Fgithub.com\u002Fpillarjs\u002Fencodeurl) for `encodePath`.\n\n### Parse\n\nThe `parse` function accepts a string and returns `TokenData`, which can be used with `match` and `compile`.\n\n- **path** A string.\n- **options** _(optional)_\n  - **encodePath** A function for encoding input strings. (default: `x => x`, recommended: [`encodeurl`](https:\u002F\u002Fgithub.com\u002Fpillarjs\u002Fencodeurl))\n\n### Tokens\n\n`TokenData` has two properties:\n\n- **tokens** A sequence of tokens, currently of types `text`, `param`, `wildcard`, or `group`.\n- **originalPath** The original path used with `parse`, shown in error messages to assist debugging.\n\n### Custom path\n\nIn 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:\n\n```js\nimport { match } from \"path-to-regexp\";\n\nconst tokens = [\n  { type: \"text\", value: \"\u002F\" },\n  { type: \"param\", name: \"foo\" },\n];\nconst originalPath = \"\u002F[foo]\"; \u002F\u002F To help debug error messages.\nconst path = { tokens, originalPath };\nconst fn = match(path);\n\nfn(\"\u002Ftest\"); \u002F\u002F=> { path: '\u002Ftest', params: { foo: 'test' } }\n```\n\n## Errors\n\nAn 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.\n\n### Missing parameter name\n\nParameter names must be provided after `:` or `*`, for example `\u002F*path`. They can be valid JavaScript identifiers (e.g. `:myName`) or JSON strings (`:\"my-name\"`).\n\n### Unexpected `?` or `+`\n\nIn past releases, `?`, `*`, and `+` were used to denote optional or repeating parameters. As an alternative, try these:\n\n- For optional (`?`), use braces: `\u002Ffile{.:ext}`.\n- For one or more (`+`), use a wildcard: `\u002F*path`.\n- For zero or more (`*`), use both: `\u002Ffiles{\u002F*path}`.\n\n### Unexpected `(`, `)`, `[`, `]`, etc.\n\nPrevious 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 match these characters literally, escape them with a backslash, e.g. `\"\\\\(\"`.\n\n### Unterminated quote\n\nParameter names can be wrapped in double quote characters, and this error means you forgot to close the quote character. For example, `:\"foo`.\n\n### Express \u003C= 4.x\n\nPath-To-RegExp breaks compatibility with Express \u003C= `4.x` in the following ways:\n\n- The wildcard `*` must have a name and matches the behavior of parameters `:`.\n- The optional character `?` is no longer supported, use braces instead: `\u002F:file{.:ext}`.\n- Regexp characters are not supported.\n- Some characters have been reserved to avoid confusion during upgrade (`()[]?+!`).\n- Parameter names now support valid JavaScript identifiers, or quoted like `:\"this\"`.\n\n## License\n\nMIT\n\n[npm-image]: https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fv\u002Fpath-to-regexp\n[npm-url]: https:\u002F\u002Fnpmjs.org\u002Fpackage\u002Fpath-to-regexp\n[downloads-image]: https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fdm\u002Fpath-to-regexp\n[downloads-url]: https:\u002F\u002Fnpmjs.org\u002Fpackage\u002Fpath-to-regexp\n[build-image]: https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002Fpillarjs\u002Fpath-to-regexp\u002Fci.yml?branch=master\n[build-url]: https:\u002F\u002Fgithub.com\u002Fpillarjs\u002Fpath-to-regexp\u002Factions\u002Fworkflows\u002Fci.yml?query=branch%3Amaster\n[coverage-image]: https:\u002F\u002Fimg.shields.io\u002Fcodecov\u002Fc\u002Fgh\u002Fpillarjs\u002Fpath-to-regexp\n[coverage-url]: https:\u002F\u002Fcodecov.io\u002Fgh\u002Fpillarjs\u002Fpath-to-regexp\n[license-image]: http:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fl\u002Fpath-to-regexp.svg?style=flat\n[license-url]: LICENSE.md\n","pillarjs\u002Fpath-to-regexp 是一个将路径字符串（如 `\u002Fuser\u002F:name`）转换为正则表达式的工具。其核心功能包括参数匹配、通配符支持及可选路径段处理，能够灵活地解析和生成URL路径。项目采用TypeScript编写，提供match、pathToRegexp、compile等API，适用于Node.js环境下需要动态路由解析的场景，比如Express.js应用中定义RESTful API路径。它特别适合于处理有序数据（例如路径、主机名），但不适合处理无序数据（如查询字符串）。MIT许可证下开源，拥有广泛的社区支持与应用实例。",2,"2026-06-11 03:27:00","top_topic"]