-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to specify types and typedMatch function on regexp ob…
…jects. This is the first step towards achieving expressjs/express#2756. /:foo{<type>} - adds a valType=<type> property to the key object - sets the pattern to match floats for 'number' and 'float' - sets the pattern to match integers for 'integer' <type> ::= string | float | number | integer A new function is added as typedMatch(str) to the regexp objects returned by pathToRegexp(...). It is a wrapper on top of String.match(regexp), and it uses the keys property to change the types of the matching groups accordingly. The changes happen for "float", "number", and "integer". The pattern is only changed when a different pattern is not defined. For example, /:foo([123]){integer} will have the pattern [123], but will also benefit from automatic type changes when using typedMatch.
- Loading branch information
1 parent
dc9a133
commit afebe50
Showing
2 changed files
with
178 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters