[utils] Handle single-line comments in js_to_json
This commit is contained in:
parent
a22b2fd19b
commit
b3ee552e4b
2 changed files with 5 additions and 2 deletions
|
@ -2107,7 +2107,7 @@ def js_to_json(code):
|
|||
v = m.group(0)
|
||||
if v in ('true', 'false', 'null'):
|
||||
return v
|
||||
elif v.startswith('/*') or v == ',':
|
||||
elif v.startswith('/*') or v.startswith('//') or v == ',':
|
||||
return ""
|
||||
|
||||
if v[0] in ("'", '"'):
|
||||
|
@ -2134,7 +2134,7 @@ def js_to_json(code):
|
|||
return re.sub(r'''(?sx)
|
||||
"(?:[^"\\]*(?:\\\\|\\['"nurtbfx/\n]))*[^"\\]*"|
|
||||
'(?:[^'\\]*(?:\\\\|\\['"nurtbfx/\n]))*[^'\\]*'|
|
||||
/\*.*?\*/|,(?=\s*[\]}])|
|
||||
/\*.*?\*/|//[^\n]*|,(?=\s*[\]}])|
|
||||
[a-zA-Z_][.a-zA-Z_0-9]*|
|
||||
\b(?:0[xX][0-9a-fA-F]+|0+[0-7]+)(?:\s*:)?|
|
||||
[0-9]+(?=\s*:)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue