Unverified Commit afd7a50a authored by Yongjun Park's avatar Yongjun Park Committed by GitHub

fix invalid comment in parseParameter function (#47291)

I noticed an incorrect comment in ```parseParameter``` function, so I fixed it and added a missing example case.
- Rename property ```name``` -> ```key```
- Add ```repeat: true, optional: false``` case

https://github.com/vercel/next.js/blob/20b8dda0e8804f3c488b569c3355647ed5da9ac8/packages/next/src/shared/lib/router/utils/route-regex.ts#L15-L21
parent 46201e16
...@@ -15,9 +15,10 @@ export interface RouteRegex { ...@@ -15,9 +15,10 @@ export interface RouteRegex {
/** /**
* Parses a given parameter from a route to a data structure that can be used * Parses a given parameter from a route to a data structure that can be used
* to generate the parametrized route. Examples: * to generate the parametrized route. Examples:
* - `[...slug]` -> `{ name: 'slug', repeat: true, optional: true }` * - `[...slug]` -> `{ key: 'slug', repeat: true, optional: true }`
* - `[foo]` -> `{ name: 'foo', repeat: false, optional: true }` * - `...slug` -> `{ key: 'slug', repeat: true, optional: false }`
* - `bar` -> `{ name: 'bar', repeat: false, optional: false }` * - `[foo]` -> `{ key: 'foo', repeat: false, optional: true }`
* - `bar` -> `{ key: 'bar', repeat: false, optional: false }`
*/ */
function parseParameter(param: string) { function parseParameter(param: string) {
const optional = param.startsWith('[') && param.endsWith(']') const optional = param.startsWith('[') && param.endsWith(']')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment