File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -106,13 +106,13 @@ export default class UrlMatcher {
106
106
// The regular expression is somewhat complicated due to the need to allow curly braces
107
107
// inside the regular expression. The placeholder regexp breaks down as follows:
108
108
// ([:*])([\w\[\]]+) - classic placeholder ($1 / $2) (search version has - for snake-case)
109
- // \{([\w\[\]]+)(?:\:( ... ))?\} - curly brace placeholder ($3) with optional regexp/type ... ($4) (search version has - for snake-case
109
+ // \{([\w\[\]]+)(?:\:\s* ( ... ))?\} - curly brace placeholder ($3) with optional regexp/type ... ($4) (search version has - for snake-case
110
110
// (?: ... | ... | ... )+ - the regexp consists of any number of atoms, an atom being either
111
111
// [^{}\\]+ - anything other than curly braces or backslash
112
112
// \\. - a backslash escape
113
113
// \{(?:[^{}\\]+|\\.)*\} - a matched set of curly braces containing other atoms
114
- var placeholder = / ( [: * ] ) ( [ \w \[ \] ] + ) | \{ ( [ \w \[ \] ] + ) (?: \: ( (?: [ ^ { } \\ ] + | \\ .| \{ (?: [ ^ { } \\ ] + | \\ .) * \} ) + ) ) ? \} / g,
115
- searchPlaceholder = / ( [: ] ? ) ( [ \w \[ \] - ] + ) | \{ ( [ \w \[ \] - ] + ) (?: \: ( (?: [ ^ { } \\ ] + | \\ .| \{ (?: [ ^ { } \\ ] + | \\ .) * \} ) + ) ) ? \} / g,
114
+ var placeholder = / ( [: * ] ) ( [ \w \[ \] ] + ) | \{ ( [ \w \[ \] ] + ) (?: \: \s * ( (?: [ ^ { } \\ ] + | \\ .| \{ (?: [ ^ { } \\ ] + | \\ .) * \} ) + ) ) ? \} / g,
115
+ searchPlaceholder = / ( [: ] ? ) ( [ \w \[ \] - ] + ) | \{ ( [ \w \[ \] - ] + ) (?: \: \s * ( (?: [ ^ { } \\ ] + | \\ .| \{ (?: [ ^ { } \\ ] + | \\ .) * \} ) + ) ) ? \} / g,
116
116
last = 0 , m , patterns = [ ] ;
117
117
118
118
const checkParamErrors = ( id ) => {
Original file line number Diff line number Diff line change @@ -546,6 +546,12 @@ describe("urlMatcherFactory", function () {
546
546
expect ( m . format ( { foo : 5 , flag : true } ) ) . toBe ( "/5/1" ) ;
547
547
} ) ;
548
548
549
+ it ( "should match built-in types with spaces" , function ( ) {
550
+ var m = new UrlMatcher ( "/{foo: int}/{flag: bool}" ) ;
551
+ expect ( m . exec ( "/1138/1" ) ) . toEqual ( { foo : 1138 , flag : true } ) ;
552
+ expect ( m . format ( { foo : 5 , flag : true } ) ) . toBe ( "/5/1" ) ;
553
+ } ) ;
554
+
549
555
it ( "should match types named only in params" , function ( ) {
550
556
var m = new UrlMatcher ( "/{foo}/{flag}" , {
551
557
params : {
You can’t perform that action at this time.
0 commit comments