Nykakin / chompjs

Parsing JavaScript objects into Python data structures
MIT License
197 stars 11 forks source link

Handle windows newlines #5

Closed Nykakin closed 4 years ago

Nykakin commented 4 years ago

Fixing throwing an exception if input string contains Windows-style newlines:

>>> chompjs.parse_js_object('{\n}')
{}
>>> chompjs.parse_js_object('{\r\n}')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/mariusz/Documents/Praca/venv/local/lib/python2.7/site-packages/chompjs/chompjs.py", line 27, in parse_js_object
    raise ValueError('Parser error: ... {}'.format(repr(str(exception))[1:-1]))
ValueError: Parser error: ... \r\n}