Add quotes for strings in javascript.assemble

This commit is contained in:
Florian Bruhin 2016-08-04 17:58:40 +02:00
parent 08b70f0f4c
commit a8ef956726
2 changed files with 3 additions and 3 deletions

View File

@ -54,7 +54,7 @@ def _convert_js_arg(arg):
if arg is None:
return 'undefined'
elif isinstance(arg, str):
return string_escape(arg)
return '"{}"'.format(string_escape(arg))
elif isinstance(arg, int):
return str(arg)
else:

View File

@ -123,8 +123,8 @@ class TestStringEscape:
@pytest.mark.parametrize('arg, expected', [
('foobar', 'foobar'),
('foo\\bar', r'foo\\bar'),
('foobar', '"foobar"'),
('foo\\bar', r'"foo\\bar"'),
(42, '42'),
(None, 'undefined'),
(object(), TypeError),