File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -430,8 +430,9 @@ namespace ts {
430
430
let nextChar = ( i + 1 < jsonText . length ) ? jsonText . charAt ( i + 1 ) : undefined ;
431
431
if ( processingString ) {
432
432
if ( currentChar === "\\"
433
- && nextChar === "\"" ) {
434
- // Escaped quote consume the 2 characters
433
+ && nextChar !== undefined ) {
434
+ // Found an escaped character
435
+ // consume the \ and the escaped char
435
436
result += currentChar ;
436
437
result += nextChar ;
437
438
i += 1 ;
Original file line number Diff line number Diff line change @@ -77,6 +77,22 @@ module ts {
77
77
}` , { config : { exclude : [ "xx/*file.d.ts*/" ] } } ) ;
78
78
} ) ;
79
79
80
+ it ( "handles escaped characters in strings correctly" , ( ) => {
81
+ assertParseResult (
82
+ `{
83
+ "exclude": [
84
+ "xx\\"//files"
85
+ ]
86
+ }` , { config : { exclude : [ "xx\"//files" ] } } ) ;
87
+
88
+ assertParseResult (
89
+ `{
90
+ "exclude": [
91
+ "xx\\\\" // end of line comment
92
+ ]
93
+ }` , { config : { exclude : [ "xx\\" ] } } ) ;
94
+ } ) ;
95
+
80
96
it ( "returns object with error when json is invalid" , ( ) => {
81
97
assertParseError ( "invalid" ) ;
82
98
} ) ;
You can’t perform that action at this time.
0 commit comments