path-to-regexp-v8-migration

Migrate @data-client/rest path strings from path-to-regexp v6 to v8 syntax.

2.0k|99|Updated Feb 15, 2019
One-click install
npx skills add https://github.com/reactive/data-client --skill path-to-regexp-v8-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: path-to-regexp-v8-migration
Source: https://github.com/reactive/data-client/tree/main/.agents/skills/path-to-regexp-v8-migration
Command: npx skills add https://github.com/reactive/data-client --skill path-to-regexp-v8-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Upgrading path-to-regexp from v6 to v8 breaks existing path strings in RestEndpoint and resource() definitions, causing runtime errors like "Unexpected ?" or "Unexpected +" during path compilation. This Skill provides the exact syntax conversion rules to update every affected path string.

Core Features & Use Cases

  • Optional Parameter Conversion: Rewrites /:id? suffix syntax into v8 brace groups like {/:id}.
  • Wildcard and Repeating Parameter Migration: Converts + and * suffixes into the *name wildcard syntax.
  • Escaping and Quoting Rules: Handles literal special characters with \\ escapes and quoted parameter names like /:"with-dash".
  • Use Case: After upgrading @data-client/rest, your app throws "Unexpected ?" errors on endpoints with optional params. Use this Skill to locate every path: string in RestEndpoint, resource(), and .extend() calls and rewrite them to valid v8 syntax.

Quick Start

Ask the AI to migrate all RestEndpoint path strings in this repository from path-to-regexp v6 to v8 syntax.

Frequently Asked Questions about path-to-regexp-v8-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate path-to-regexp v6 optional parameters to v8?

Replace the `?` suffix with brace groups that wrap the optional segment including its prefix. For example, `/:id?` becomes `{/:id}` and `/users/:id?` becomes `/users{/:id}`.

How do I convert repeating parameters like :path+ in path-to-regexp v8?

The `+` and `*` suffixes were removed in v8. Use wildcard syntax instead: `/:path+` becomes `/*path` and `/:path*` becomes `{/*path}` for the zero-or-more case.

Why does path-to-regexp v8 throw "Unexpected ?" errors?

In v8, `?` starts a modifier, so a literal question mark in a URL path must be escaped as `\\?`. For optional path params, replace the trailing `?` on `:name` with the `{/:name}` group syntax instead.

Does path-to-regexp v8 support inline regex like /:id(\d+)?

No, custom inline regex patterns were removed in v8. Strip the regex portion so `/:id(\d+)` becomes simply `/:id`, and enforce any format constraints elsewhere in your application logic.

Where should I look for path strings that need migration in a data-client codebase?

Search for `path:` properties in RestEndpoint, resource(), and .extend() calls. Also check docs under docs/rest/api/, type tests in typescript-tests/, and blog posts or changelogs containing code examples.