File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,6 +57,18 @@ Done.`),
5757 expect ( ( ) => decodeLenientJson ( '{ "enabled": true,, }' ) ) . toThrow ( ) ;
5858 } ) ;
5959
60+ it . each ( [
61+ "[1/* https://example.com */2]" ,
62+ "[1/* https://example.com */.5]" ,
63+ "[tr/* https://example.com */ue]" ,
64+ ] ) ( "rejects tokens separated by a block comment in %s" , ( input ) => {
65+ expect ( ( ) => decodeLenientJson ( input ) ) . toThrow ( ) ;
66+ } ) ;
67+
68+ it ( "preserves comment markers inside string values" , ( ) => {
69+ expect ( decodeLenientJson ( '"1/* https://example.com */2"' ) ) . toBe ( "1/* https://example.com */2" ) ;
70+ } ) ;
71+
6072 it . each ( [
6173 '{ /* See https://example.com/config */ "enabled": true }' ,
6274 '{ "enabled": /* // this is still a block comment */ true }' ,
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ const parseLenientJsonGetter = SchemaGetter.transformEffect((input: string) => {
168168 // The string alternation preserves quoted values.
169169 let stripped = input . replace (
170170 / ( " (?: [ ^ " \\ ] | \\ .) * " ) | \/ \/ [ ^ \n ] * | \/ \* [ \s \S ] * ?\* \/ / g,
171- ( match , stringLiteral : string | undefined ) => ( stringLiteral ? match : "" ) ,
171+ ( match , stringLiteral : string | undefined ) => ( stringLiteral ? match : " " ) ,
172172 ) ;
173173
174174 // Strip trailing commas before `}` or `]`. The alternation preserves quoted
You can’t perform that action at this time.
0 commit comments