Cross-platform, efficient, customizable, and robust asynchronous HTTP(S)/WebSocket server C++ library with the right balance between performance and ease of use
Other
1.16k
stars
93
forks
source link
Update path2regex (third time's the charm, hopefully.) #171
I've corrected several errors in my port of the newer javascript code. Behavior should now be identical to path-regexp@6.2.0; and I've updated the test suite to reflect this.
There's still going to be breaking changes for some people, but they'll likely be things path-to-regexp itself already had a while ago. Not all of these have yet made it into express.js, though., given that the 5.0 betas depend on path-to-regexp 3.2.0
From documentation of path-to-regexp, main changes are (most are copied from the path-to-regexp release notes):
This time around, I tested it using C++14, and all tests were passing.
Allow empty string with ending: false to match both relative and absolute paths
Use delimiter when processing repeated matching groups (e.g. foo/bar has no prefix, but has a delimiter)
Support starting option to disable anchoring from beginning of the string
Various enhancements from path-to-regexp 6.0, which are intended partly to restore some compatibility with older versions:
Support for nested non-capturing groups in regexp, e.g. /(abc(?=d))
Support for custom prefix and suffix groups using /{abc(.*)def}
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
Support custom prefixes (same as delimiters in RESTinio) option (default is /. which acts like every version since 0.x again)
Add support for {} to capture prefix/suffix explicitly, enables custom use-cases like /:attr1{-:attr2}?
Use /#? as default (end)delimiter to avoid matching on query or fragment parameters; if you are matching non-paths (e.g. hostnames), you can set delimiterto .
Fix invalid matching of :name* parameter
I've updated the test suite to reflect the changes, as well as added some new tests that had been added to the upstream path-to-regexp as well.
I've corrected several errors in my port of the newer javascript code. Behavior should now be identical to
path-regexp@6.2.0
; and I've updated the test suite to reflect this.There's still going to be breaking changes for some people, but they'll likely be things
path-to-regexp
itself already had a while ago. Not all of these have yet made it into express.js, though., given that the 5.0 betas depend onpath-to-regexp 3.2.0
From documentation of path-to-regexp, main changes are (most are copied from the path-to-regexp release notes):
This time around, I tested it using C++14, and all tests were passing.
ending: false
to match both relative and absolute pathsfoo/bar
has no prefix, but has a delimiter)starting
option to disable anchoring from beginning of the string/(abc(?=d))
/{abc(.*)def}
/test(foo
previously worked treating ( as a literal character, now it expects ( to be closed and is treated as a group/test\(foo
prefixes
(same asdelimiters
in RESTinio) option (default is/.
which acts like every version since 0.x again){}
to capture prefix/suffix explicitly, enables custom use-cases like/:attr1{-:attr2}?
/#?
as default (end)delimiter
to avoid matching on query or fragment parameters; if you are matching non-paths (e.g. hostnames), you can setdelimiter
to.
I've updated the test suite to reflect the changes, as well as added some new tests that had been added to the upstream
path-to-regexp
as well.