Breaking
-
Optional wildcard patterns are now fully supported! (#25): 422f630, 5362fba
Previously, an optional wildcard pattern would parse but it didn't behave correctly.
Essentially the "optional" part (?
) was ignored, meaning that optional wildcards were no different than wildcards.
This has been fixed (thanks @benmerckx), but doing so changed the generatedRegExp
(and thus, the matching behavior) for the optional wildcard pattern use case.All other usage is unaffected!
The majority of use cases will see no difference – especially since the previous behavior was unwanted/unexpected anyway.let { pattern } = parse('/users/*?'); // Before: pattern.test('/users'); //=> false << wonky ❌ pattern.test('/users/'); //=> true pattern.test('/users/123'); //=> true // After: pattern.test('/users'); //=> true << YAY ✅ pattern.test('/users/'); //=> true pattern.test('/users/123'); //=> true
-
Renamed the reserved wildcard key (for wildcard value segment) from
wild
to*
:
This allows users to now construct named route patterns using the "wild" placeholder// Before: parse("/books/:genre/*"); //=> { keys: ["genre", "wild"], ... } parse("/:wild"); //=> { keys: ["wild"], ... } // ^^ this meant a named parameter would present like a wildcard, bad! ❌ // After: parse("/books/:genre/*"); //=> { keys: ["genre", "*"], ... } parse("/:wild"); //=> { keys: ["wild"], ... } // ^^ this allows named parameter to look like a named parameter, good! ✅
Features
- Support optional wildcards (#25): 5362fba
Thank you @benmerckx~!
Chores
- Update module size: 4ee42b4
Full Changelog: v2.0.2...v3.0.0