[utils] js_to_json: Fix line comment removal (#17845)

Authored by: doe1080
This commit is contained in:
doe1080
2026-12-01 06:14:19 +00:00
committed by GitHub
parent cb97503d92
commit 0e4dc0b041
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -1273,6 +1273,11 @@ class TestUtil(unittest.TestCase):
on = js_to_json('[//comment\n"abc" //comment\n,//comment\n"def",//comment\n]')
self.assertEqual(json.loads(on), ['abc', 'def'])
self.assertEqual(json.loads(js_to_json('[1]//comment')), [1])
for newline in ('\n', '\r\n', '\r', '\u2028', '\u2029'):
with self.subTest(newline=newline):
self.assertEqual(json.loads(js_to_json(f'[1,//comment{newline}2,\n3]')), [1, 2, 3])
on = js_to_json('{"abc": "def",}')
self.assertEqual(json.loads(on), {'abc': 'def'})