Skip to main content

path-to-regexp-v8-migration

Migrate @data-client/rest path strings from path-to-regexp v6 to v8 syntax. Use when upgrading path-to-regexp, updating RestEndpoint.path or resource path strings, or when seeing errors about unexpected ?, +, (, or ) in paths.

소스 정보

저장소
reactive/data-client
최근 소스 활동
2026년 8월 19일 17:11
감지된 SKILL.md 언어
영어
스타
2,038
포크
98

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
path-to-regexp-v8-migration
description
Migrate @data-client/rest path strings from path-to-regexp v6 to v8 syntax. Use when upgrading path-to-regexp, updating RestEndpoint.path or resource path strings, or when seeing errors about unexpected ?, +, (, or ) in paths.
# path-to-regexp v6 → v8 Migration Applies to `path` in `RestEndpoint`, `resource()`, and any string passed to path-to-regexp. Reference: [path-to-regexp README errors section](https://github.com/pillarjs/path-to-regexp#errors) ## Migration Rules ### Optional parameters `?` suffix removed. Wrap the optional segment (including its prefix) in `{}`. ``` /:id? → {/:id} /users/:id? → /users{/:id} /files/:name? → /files{/:name} ``` ### Repeating parameters `+` (one-or-more) and `*` (zero-or-more) suffixes removed. Use `*name` wildcard syntax. ``` /:path+ → /*path /:path* → {/*path} ``` ### Quoted parameter names Parameter names must be valid JS identifiers. Names with special characters need double quotes. ``` /:with-dash → /:"with-dash" /:my.param → /:"my.param" ``` ### Escaping special characters Characters including `{}()[]+?!:*\\` must be escaped with `\\` when used as **literals** (see [path-to-regexp errors](https://github.com/pillarjs/path-to-regexp#errors)). A literal `?` in the path (e.g. before fixed query text like `?per_page=50`) must stay as `\\?` in the source string — removing the backslash causes `Unexpected ?` at `compile()` time. ``` /(literal) → /\\(literal\\) /[bracket] → /\\[bracket\\] /a+b → /a\\+b (+ is special unless escaped) /resource?p=1 → /resource\\?p=1 (? starts a modifier unless escaped) ``` Optional path params no longer use a trailing `?` on `:name` — use `{/:name}` instead (see above); that is different from a **literal** `?` in the URL. ### Custom regex removed Inline regex like `/:id(\d+)` is no longer supported. Remove regex patterns. ``` /:id(\d+) → /:id ``` ## Combined Examples Optional with prefix: ``` /:attr1?{-:attr2}?{-:attr3}? → {/:attr1}{-:attr2}{-:attr3} ``` Query params embedded in path (prefer grouped params; do **not** drop `\\` before a literal `?` unless you rewrite to this form): ``` /search\\?q=:q?&page=:page? → /search?{q=:q}{&page=:page} ``` ## Where to Find Paths Search patterns for locating v6 paths in a codebase: - `path:` properties in `RestEndpoint`, `resource()`, `.extend()` calls - Docs under `docs/rest/api/` - Type tests in `typescript-tests/` - Blog posts and changelogs with code examples ## Type System `pathTypes.ts` infers TypeScript parameter types from path strings: - `:name` and `*name` → required parameter - `{/:name}` and `{/*name}` → optional parameter (trailing `}` signals optionality) - `:"quoted"` → `CleanKey` strips quotes for the property name - `\\:` / `\\*` / `\\}` → escaped, not treated as parameters
GitHub에서 보기