Change8

route-pattern@0.24.0

Breaking Changes
📦 remixView on GitHub →
6 breaking7 features🔧 7 symbols

Summary

Introduced a new delimiter-bounded route matching system with enhanced pattern capabilities and resource limits. Updated `createHref` to accept an options object for search parameters and improved URL handling with `baseURL`.

⚠️ Breaking Changes

  • Route matching now uses delimiter-bounded params and a bounded state compiler. Pathname params possessively capture through hyphens but stop at raw `/` or `.`. Patterns such as `/:year-:month` must migrate to one inseparable param such as `/:date`, or place captures in separate delimiter-bounded segments.
  • Patterns may contain any number of separated wildcards and optional groups without eagerly expanding variants or using backtracking regular expressions. Adjacent wildcards, empty optionals, params followed by non-delimiter text, and ambiguous adjacent optional capture schemas now throw `ParseError`.
  • Static pattern text is decoded during matching, while raw and percent-encoded `/` and `.` retain distinct structural meaning.
  • Matchers also accept configurable pattern-size, matcher-size, and match-work limits through `MatcherOptions.limits`; exceeding a limit throws `MatcherResourceError` with structured details.
  • `createHref(pattern, params, searchParams)` now accepts an options object as its third argument. Move existing search parameters to `createHref(pattern, params, { searchParams })`.
  • Matchers now accept relative URL strings when an absolute `baseURL` is provided to `match()` or `matchAll()`. `createHref()` accepts the same `baseURL` option and returns path-relative references for same-origin targets while leaving cross-origin targets absolute.

Migration Steps

  1. For route matching, migrate patterns like `/:year-:month` to `/:date` or place captures in separate delimiter-bounded segments.
  2. Move existing search parameters in `createHref` calls to the new options object: `createHref(pattern, params, { searchParams })`.

✨ New Features

  • Route matching now uses delimiter-bounded params and a bounded state compiler, allowing for more robust pattern matching and handling of special characters.
  • Patterns can now contain any number of separated wildcards and optional groups without eagerly expanding variants or using backtracking.
  • Matchers accept configurable pattern-size, matcher-size, and match-work limits.
  • `createHref` now accepts an options object for search parameters.
  • Matchers accept relative URL strings when an absolute `baseURL` is provided.
  • `createHref` accepts a `baseURL` option and returns path-relative references for same-origin targets while leaving cross-origin targets absolute.
  • The `searchParams` option accepts both typed plain objects and `URLSearchParams`; repeated `URLSearchParams` entries retain their order.

Affected Symbols