Skip to content

Releases: pillarjs/path-to-regexp

Wildcard, unicode, and modifier changes

20 Jun 23:27
ec35fbd
Compare
Choose a tag to compare

Hi all! There's a few major breaking changes in this release so read carefully.

Breaking changes:

  • Parameter names can now contain all unicode identifier characters (defined as regex \p{XID_Continue}).
  • No more implied prefix with / and . (this is relevant when using ?, *, or +)
  • Modifiers (?, *, +) must be used after a param explicitly wrapped in {}
  • The API is no longer supporting arrays or regexes as input
  • The wildcard (standalone *) has been added back and matches Express.js expected behavior
  • Removed endsWith option
  • Renamed strict: true to trailing: false
  • Reserved ;, ,, !, and @ for future use-cases
  • Removed tokensToRegexp, tokensToFunction and regexpToFunction in favor of simplifying exports
  • Enable a "loose" mode by default, so / can be repeated multiple times in a matched path (i.e. /foo works like //foo, etc)
  • encode and decode no longer receive the token as the second parameter
  • Removed the ESM + CommonJS dual package in favor of only one CommonJS supported export
  • Minimum JS support for ES2020 (previous ES2015)
  • Stricter compile function - expects an array of strings in repeated parameters, and strings in non-repeated parameters

Added:

  • Adds encodePath to fix an issue around encode being used for both path and parameters (the path and parameter should be encoded slightly differently)
  • Adds loose as an option to support arbitrarily matching the delimiter in paths, e.g. foo/bar and foo///bar should work the same
  • Allow encode and decode to be set to false which skips all processing of the parameters input/output
  • All remaining methods support TokenData (exported, returned by parse) as input
    • This should be useful if you are programmatically building paths to match or want to avoid parsing multiple times

Requests for feedback:

  • Requiring {} is an obvious drawback but I'm seeking feedback on whether it helps make path behavior clearer
    • Related: Removing / and . as implicit prefixes
  • Removing array and regex support is to reduce the overall package size for things many users don't need
  • Unicode IDs are added to align more closely with browser URLPattern behavior, which uses JS identifiers

v6.2.2...v7.0.0

Updated README

07 Apr 04:17
28a5b27
Compare
Choose a tag to compare

No API changes. Documentation only release.

Changed

v6.2.1...v6.2.2

Support named matching groups in `RegExp`

07 Apr 03:55
51a1955
Compare
Choose a tag to compare

Added

v0.1.7...v0.1.8

Fix matching `:name*` parameter

06 May 22:01
b0778f5
Compare
Choose a tag to compare

Fixed

  • Fix invalid matching of :name* parameter (#261) 762bc6b
  • Compare delimiter string over regexp 86baef8

Added

v6.2.0...v6.2.1

Named Capturing Groups

29 Sep 17:24
Compare
Choose a tag to compare

Added

  • Support named capturing groups for RegExps (#225)

Fixed

  • Update strict flag documentation (#227)
  • Ignore test files when bundling (#220)

Use `/#?` as Default Delimiter

20 Nov 19:27
Compare
Choose a tag to compare

Fixed

  • Use /#? as default delimiter to avoid matching on query or fragment parameters
    • If you are matching non-paths (e.g. hostnames), you can adjust delimiter: '.'

Custom Prefix and Suffix Groups

20 Nov 04:17
Compare
Choose a tag to compare

Note: The path syntax has been stabilized with this release, no breaking changes in paths is expected.

This release reverts the prefix behavior added in v3 back to the behavior seen in v2. For the most part, path matching is backward compatible with v2 with these enhancements:

  1. Support for nested non-capturing groups in regexp, e.g. /(abc(?=d))
  2. Support for custom prefix and suffix groups using /{abc(.*)def}
  3. Tokens in an unexpected position will throw an error
    • Paths like /test(foo previously worked treating ( as a literal character, now it expects ( to be closed and is treated as a group
    • You can escape the character for the previous behavior, e.g. /test\(foo

Changed

  • Revert using any character as prefix, support prefixes option to configure this (starts as /. which acts like every version since 0.x again)
  • Add support for {} to capture prefix/suffix explicitly, enables custom use-cases like /:attr1{-:attr2}?

Remove Default Encode URI Component

12 Nov 12:05
Compare
Choose a tag to compare

No changes to path rules since 3.x, except support for nested RegEx parts in 4.x.

Changed

  • Rename RegexpOptions interface to TokensToRegexpOptions
  • Remove normalizePathname from library, document solution in README
  • Encode using identity function as default, not encodeURIComponent

Decode URI

12 Nov 11:39
Compare
Choose a tag to compare

Removed

  • Remove whitelist in favor of decodeURI (advanced behavior can happen outside path-to-regexp)

Remove `String#normalize`

12 Nov 07:20
Compare
Choose a tag to compare

Fixed

  • Remove usage of String.prototype.normalize to continue supporting IE