File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,18 @@ describe("path-to-regexp", () => {
31
31
) ;
32
32
} ) ;
33
33
34
+ it ( "should throw on unmatched )" , function ( ) {
35
+ expect ( ( ) => match ( "/:fooab)c" ) ) . toThrow (
36
+ new TypeError ( "Unmatched ) at 7: https://git.new/pathToRegexpError" ) ,
37
+ ) ;
38
+ } ) ;
39
+
40
+ it ( "should throw on unmatched ) after other patterns" , function ( ) {
41
+ expect ( ( ) => match ( "/:test(\\w+)/:foo(\\d+))" ) ) . toThrow (
42
+ new TypeError ( "Unmatched ) at 21: https://git.new/pathToRegexpError" ) ,
43
+ ) ;
44
+ } ) ;
45
+
34
46
it ( "should throw on missing pattern" , ( ) => {
35
47
expect ( ( ) => match ( "/:foo()" ) ) . toThrow (
36
48
new TypeError (
Original file line number Diff line number Diff line change @@ -199,6 +199,10 @@ function lexer(str: string) {
199
199
continue ;
200
200
}
201
201
202
+ if ( value === ")" ) {
203
+ throw new TypeError ( `Unmatched ) at ${ i } : ${ DEBUG_URL } ` ) ;
204
+ }
205
+
202
206
tokens . push ( { type : "CHAR" , index : i , value : chars [ i ++ ] } ) ;
203
207
}
204
208
You can’t perform that action at this time.
0 commit comments