File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
extension/src/json-viewer Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -71,14 +71,15 @@ function wrapNumbers(text) {
7171 var buffer = "" ;
7272 var numberBuffer = "" ;
7373 var isInString = false ;
74+ var charIsEscaped = false ;
7475 var isInNumber = false ;
7576 var previous = "" ;
7677 var beforePrevious = "" ;
7778
7879 for ( var i = 0 , len = text . length ; i < len ; i ++ ) {
7980 var char = text [ i ] ;
8081
81- if ( char == '"' && ( previous != '\\' || ( previous == '\\' && beforePrevious == '\\' ) ) ) {
82+ if ( char == '"' && ! charIsEscaped ) {
8283 isInString = ! isInString ;
8384 }
8485
@@ -99,6 +100,9 @@ function wrapNumbers(text) {
99100 numberBuffer = "" ;
100101 }
101102
103+ // this applies to the _next_ character - the one used in the next iteration
104+ charIsEscaped = ( char == '\\' ) ? ! charIsEscaped : false
105+
102106 if ( isInNumber ) {
103107 numberBuffer += char ;
104108
Original file line number Diff line number Diff line change 11{
2+ "triple-backslash" : " \\\" 99\\\" " ,
23 "path" : " C:\\ foobar\\ " ,
34 "number" : 123 ,
45 "foo" : " bar"
You can’t perform that action at this time.
0 commit comments