@@ -19,7 +19,7 @@ import {
1919 * Dynamically generate the entire test suite.
2020 */
2121describe ( "path-to-regexp" , ( ) => {
22- describe ( "ParseError " , ( ) => {
22+ describe ( "PathError " , ( ) => {
2323 it ( "should contain original path and debug url" , ( ) => {
2424 const error = new PathError (
2525 "Unexpected end at index 7, expected }" ,
@@ -77,6 +77,36 @@ describe("path-to-regexp", () => {
7777 new PathError ( "Unterminated quote at index 2" , '/:"foo' ) ,
7878 ) ;
7979 } ) ;
80+
81+ it ( "should throw on eol backslash" , ( ) => {
82+ expect ( ( ) => parse ( "/foo\\" ) ) . toThrow (
83+ new PathError ( "Unexpected end after \\ at index 5" , "/foo\\" ) ,
84+ ) ;
85+ } ) ;
86+
87+ it ( "should throw on eol backslash in group" , ( ) => {
88+ expect ( ( ) => parse ( "/foo/{bar\\" ) ) . toThrow (
89+ new PathError ( "Unexpected end after \\ at index 10" , "/foo/{bar\\" ) ,
90+ ) ;
91+ } ) ;
92+
93+ it ( "should throw on eol backslash after param" , ( ) => {
94+ expect ( ( ) => parse ( "/foo/:bar\\" ) ) . toThrow (
95+ new PathError ( "Unexpected end after \\ at index 10" , "/foo/:bar\\" ) ,
96+ ) ;
97+ } ) ;
98+
99+ it ( "should throw on eol backslash after wildcard" , ( ) => {
100+ expect ( ( ) => parse ( "/foo/*bar\\" ) ) . toThrow (
101+ new PathError ( "Unexpected end after \\ at index 10" , "/foo/*bar\\" ) ,
102+ ) ;
103+ } ) ;
104+
105+ it ( "should throw on eol backslash in quoted param" , ( ) => {
106+ expect ( ( ) => parse ( '/foo/:"bar\\' ) ) . toThrow (
107+ new PathError ( "Unterminated quote at index 6" , '/foo/:"bar\\' ) ,
108+ ) ;
109+ } ) ;
80110 } ) ;
81111
82112 describe ( "compile errors" , ( ) => {
0 commit comments