npm / path-to-regexp
path-to-regexp
What changed in path-to-regexp 1 to 9, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
36 breaking2 security9 new APIs and options6 performance5 behavior and defaults6 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initpath-to-regexp 911 changes
Breaking changes 9
Compilation now rejects an empty-string parameter.
Compilation now rejects a wildcard array that produces an empty path.
The Keys type has been removed.
For ambiguous matches with two or more parameters in a segment, the last parameter is now greedy instead of the first.
The package now requires Node.js 22 or newer.
The package is now ESM only, so developers must use it as an ES module.
Stringification now quotes parameter names followed by astral ID_Continue text.
The TokenData class has been removed.
A path that explicitly provides its trailing delimiter, such as
/foo/, no longer appends an extra optional delimiter.
Fixes and other changes 2
Stringifying parameter names with control characters is fixed.
Stringification lookahead across empty text tokens is fixed.
path-to-regexp 818 changes
Breaking changes 4
Limits generated combinations for optional route groups to fewer than 256, rejecting large combinations to avoid regex size explosions.
The ?, +, and * group suffixes are removed; use wildcards for + and {*foo} for *.
The loose mode is removed.
Regular expression overrides of parameters are removed.
Security 2
path-to-regexp vulnerable to Denial of Service via sequential optional groups
Restricts wildcard backtracking when a path uses more than one wildcard, addressing the listed security vulnerabilities.
New APIs and options 3
Match accepts an array of string or TokenData values in addition to a single string or TokenData.
Wildcards can have key names using *name syntax, aligning with : behavior.
Parameter names can be quoted, allowing names such as foo-bar.
Performance 5
Minimizes array allocations.
Reduces bundle size from 1.97 kB to 1.93 kB.
Improves compile performance by about 25%.
Removes internal tokenization during parse, which should improve parse performance by about 20%.
Deduplicates regex prefixes, resulting in shorter regular expressions for some cases using optional groups.
Behavior and default changes 1
Parameter names follow JavaScript identifier rules and allow Unicode characters.
Fixes and other changes 3
Fixes an error caused by a trailing backslash.
Backtrack handling now allows a parameter to match itself, including matching the second underscore in
/foo__.Wildcards in non-ending mode no longer stop at the first match, avoiding truncated matches.
path-to-regexp 721 changes
Breaking changes 15
Arrays and regular expressions are no longer supported as inputs.
The ESM and CommonJS dual package is removed in favor of a single supported CommonJS export.
The function returned by compile accepts only string values; repeated values must be arrays of strings when encode is not false.
decode now defaults to decodeURIComponent.
encode and decode no longer receive the token as their second parameter.
encode now defaults to encodeURIComponent.
The endsWith option has been removed.
The minimum JavaScript support level is ES2020, raised from ES2015.
Loose matching is enabled by default, allowing repeated / characters in matched paths; loose can also be set as an option to match delimiters arbitrarily.
Modifiers ?, *, and + must follow a parameter explicitly wrapped in {}; / and . are no longer implied prefixes.
regexpToFunction has been removed as exports are simplified.
Semicolon, comma, exclamation mark, and at sign are reserved for future use cases.
tokensToFunction has been removed as exports are simplified.
tokensToRegexp has been removed as exports are simplified.
The former strict: true setting is renamed to trailing: false.
New APIs and options 4
decode can be set to false to skip all processing of parameter input and output.
encode can be set to false to skip all processing of parameter input and output.
Adds encodePath to handle the difference between encoding paths and parameters.
All remaining methods accept TokenData, exported and returned by parse, as input, allowing programmatically built paths or avoiding repeated parsing.
Behavior and default changes 1
Parameter names can contain all Unicode identifier characters defined by \p{XID_Continue}.
Fixes and other changes 1
The standalone wildcard is available again and matches Express.js expected behavior.
path-to-regexp 64 changes
Breaking changes 2
The prefixes option configures which characters can act as prefixes; it starts as
/., reverting the prefix behavior added in v3.Tokens in unexpected positions now throw an error; an unclosed
(is treated as a group and can be escaped to remain literal.
New APIs and options 1
Braces capture prefix and suffix explicitly, enabling custom use cases such as
/:attr1{-:attr2}?.
Behavior and default changes 1
Regular expressions now support nested non-capturing groups.
path-to-regexp 53 changes
Breaking changes 3
Encoding now uses the identity function by default instead of encodeURIComponent.
normalizePathname was removed from the library; the README documents a solution.
The RegexpOptions interface was renamed to TokensToRegexpOptions.
path-to-regexp 46 changes
Breaking changes 3
Export names changed to support ES2015 modules in bundlers.
match no longer defaults to decodeURIComponent.
Path rules remain backward compatible with 3.x except nested
()and other RegEx special characters that were previously ignored.
New APIs and options 1
A new utility supports unicode paths in libraries.
Performance 1
ES2015 modules enable tree-shaking for webpack and other bundlers.
Behavior and default changes 1
Nested non-capturing groups are supported within parameters.
path-to-regexp 11 changes
Behavior and default changes 1
The release states there will be no more API changes.