route-pattern@0.23.0
Breaking Changes📦 remixView on GitHub →
⚠ 1 breaking✨ 4 features🐛 10 fixes🔧 13 symbols
Summary
This release introduces breaking changes to how RoutePattern internals are accessed, requiring consumers to use public methods like .source or .toJSON(). It also includes numerous bug fixes related to route pattern matching, href generation, and type safety for literal patterns.
⚠️ Breaking Changes
- The `RoutePattern` object no longer exposes its parsed internals directly. Consumers must now use `RoutePattern.parse()` to construct patterns and access properties via `pattern.source`, `pattern.toString()`, or `pattern.toJSON()` instead of accessing internal properties like `pattern.pathname.tokens`, `pattern.hostname`, or `pattern.search`.
Migration Steps
- If accessing internal properties of a `RoutePattern` object (e.g., `pattern.pathname.tokens`), switch to using the public methods: `pattern.source`, `pattern.toString()`, or `pattern.toJSON()`.
- If inspecting route pattern captures, use the new utility function `getRoutePatternCaptures(pattern)` instead of accessing internal tokens.
✨ New Features
- Added `getRoutePatternCaptures(pattern)` utility to inspect route pattern captures (variables and wildcards) without relying on internal parser tokens. It returns readonly entries describing `{ part, type, name, optional }` in source order.
- Exported `RoutePatternCapture` and `RoutePatternJSON` from `@remix-run/route-pattern`.
- Exported `CreateHrefErrorDetails` from `@remix-run/route-pattern/href`.
- Exported `MatchParamMeta` from `@remix-run/route-pattern/match`.
🐛 Bug Fixes
- Fixed route pattern matching and href generation so that `ignoreCase` applies consistently to pathname matching.
- Fixed route pattern matching so that key-only search constraints result in matchable generated hrefs.
- Fixed pathname parameters to use `encodeURIComponent` for segment encoding.
- Fixed hostname parameters to reject URL-structural and control characters.
- Fixed optional joins to prevent generation of duplicate slashes.
- Fixed missing-param errors to report every missing required parameter.
- Fixed optional variant duplicates to be collapsed.
- Fixed rejection of port-only origins.
- Fixed protocol/port constraints to correctly participate in specificity calculations.
- Fixed route pattern helper types so that literal pattern types adhere to the same grammar as runtime parsing, causing invalid literal patterns to evaluate to `never` in `CreateHrefArgs`, `MatchParams`, and `JoinPatterns`.