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
totrailing: false
- Removed the ES2015 bundle in favor of only one CommonJS supported export
- Reserved
;
,,
,!
, and@
for future use-cases - Removed
tokensToRegexp
,tokensToFunction
andregexpToFunction
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
anddecode
no longer give token information as the second parameter
Added:
- Adds
encodePath
to fix an issue aroundencode
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
andfoo///bar
should work the same - Allow
encode
anddecode
to be set tofalse
which skips all processing of the parameters input/output
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
- Related: Removing
- 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