path-to-regexp

Turn a path string such as `/user/:name` into a regular expression

MIT License

Downloads
246.3M
Stars
7.9K
Committers
34

Bot releases are hidden (Show)

path-to-regexp - Support array inputs (again)

Published by blakeembrey about 1 month ago

Added

  • Support array inputs for match and pathToRegexp 3fdd88f

https://github.com/pillarjs/path-to-regexp/compare/v7.1.0...v7.2.0

path-to-regexp - v8.1.0

Published by blakeembrey about 1 month ago

Added

  • Adds pathToRegexp method back for generating a regex
  • Adds stringify method for converting TokenData into a path string

https://github.com/pillarjs/path-to-regexp/compare/v8.0.0...v8.1.0

path-to-regexp - Simpler API

Published by blakeembrey about 2 months ago

Heads up! This is a fairly large change (again) and I need to apologize in advance. If I foresaw what this version would have ended up being I would not have released version 7. A longer blog post and explanation will be incoming this week, but the pivot has been due to work on Express.js v5 and this will the finalized syntax used in Express moving forward.

Added

  • Adds key names to wildcards using *name syntax, aligns with : behavior but using an asterisk instead

Changed

  • Removes group suffixes of ?, +, and * - only optional exists moving forward (use wildcards for +, {*foo} for *)
  • Parameter names follow JS identifier rules and allow unicode characters

Added

  • Parameter names can now be quoted, e.g. :"foo-bar"
  • Match accepts an array of values, so the signature is now string | TokenData | Array<string | TokenData>

Removed

  • Removes loose mode
  • Removes regular expression overrides of parameters

https://github.com/pillarjs/path-to-regexp/compare/v7.1.0...v8.0.0

path-to-regexp - Backtrack protection

Published by blakeembrey about 2 months ago

Fixed

  • Add backtrack protection to parameters 29b96b4
    • This will break some edge cases but should improve performance

https://github.com/pillarjs/path-to-regexp/compare/v0.1.9...v0.1.10

path-to-regexp - Support non-lookahead regex output

Published by blakeembrey about 2 months ago

Added

  • Allow a non-lookahead regex (#312) c4272e4

https://github.com/component/path-to-regexp/compare/v0.1.8...v0.1.9

path-to-regexp - Strict mode Latest Release

Published by blakeembrey 3 months ago

Added

  • Adds a strict option to detect potential ReDOS issues

Fixed

  • Fixes separator to default to suffix + prefix when not specified
  • Allows separator to be undefined in TokenData
    • This is only relevant if you are building TokenData manually, previously parse filled it in automatically

Comments

  • I highly recommend enabling strict: true and I'm probably releasing a V8 with it enabled by default ASAP as a necessary security mitigation

https://github.com/pillarjs/path-to-regexp/compare/v7.0.0...v7.1.0

path-to-regexp - Wildcard, unicode, and modifier changes

Published by blakeembrey 4 months ago

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

Breaking changes:

  • The function returned by compile only accepts strings as values (i.e. no numbers, use String(value) before compiling a path)
    • For repeated values, when encode !== false, it must be an array of strings
  • Parameter names can contain all unicode identifier characters (defined as regex \p{XID_Continue}).
  • Modifiers (?, *, +) must be used after a param explicitly wrapped in {}
    • No more implied prefix of / or .
  • No support for arrays or regexes as inputs
  • 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)
  • Encode defaults to encodeURIComponent and decode defaults to decodeURIComponent

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

https://github.com/pillarjs/path-to-regexp/compare/v6.2.2...v7.0.0

path-to-regexp - Updated README

Published by blakeembrey 7 months ago

No API changes. Documentation only release.

Changed

  • Fix readme example c7ec332
  • Update shield URL e828000

https://github.com/pillarjs/path-to-regexp/compare/v6.2.1...v6.2.2

path-to-regexp - Support named matching groups in `RegExp`

Published by blakeembrey 7 months ago

Added

  • Add support for named matching groups (#301) 114f62d

https://github.com/pillarjs/path-to-regexp/compare/v0.1.7...v0.1.8

path-to-regexp - Fix matching `:name*` parameter

Published by blakeembrey over 2 years ago

Fixed

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

Added

  • New example in documentation (#256) ae9e576
  • Update demo link (#250) 77df638
  • Update README encode example b39edd4

https://github.com/pillarjs/path-to-regexp/compare/v6.2.0...v6.2.1

path-to-regexp - Named Capturing Groups

Published by blakeembrey about 4 years ago

Added

  • Support named capturing groups for RegExps (#225)

Fixed

  • Update strict flag documentation (#227)
  • Ignore test files when bundling (#220)
path-to-regexp - Use `/#?` as Default Delimiter

Published by blakeembrey almost 5 years ago

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: '.'
path-to-regexp - Custom Prefix and Suffix Groups

Published by blakeembrey almost 5 years ago

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}?
path-to-regexp - Remove Default Encode URI Component

Published by blakeembrey almost 5 years ago

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
path-to-regexp - Decode URI

Published by blakeembrey almost 5 years ago

Removed

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

Published by blakeembrey almost 5 years ago

Fixed

  • Remove usage of String.prototype.normalize to continue supporting IE
path-to-regexp - Normalize Path Whitelist

Published by blakeembrey almost 5 years ago

Added

  • Add normalize whitelist of characters (defaults to /%.-)
path-to-regexp - Allow `RegexpOptions` in `match`

Published by blakeembrey almost 5 years ago

Fixed

  • Allow RegexpOptions in match(...) function
path-to-regexp - Fix Spelling of Regexp

Published by blakeembrey almost 5 years ago

Fixed

  • Normalize regexp spelling across 4.x
path-to-regexp - ES2015 Package for Bundlers

Published by blakeembrey almost 5 years ago

All path rules are backward compatible with 3.x, except for nested () and other RegEx special characters that were previously ignored.

Changed

  • Export names have changed to support ES2015 modules in bundlers
  • match does not default to decodeURIComponent

Added

  • New normalizePathname utility for supporting unicode paths in libraries
  • Support nested non-capturing groups within parameters
  • Add tree-shaking (via ES2015 modules) for webpack and other bundlers