diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index ceaf36d30..9897c3db2 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -113,6 +113,12 @@ class TestJSInterpreter(unittest.TestCase): self.assertEqual(jsi.call_function('z'), 5) jsi = JSInterpreter('function x(a) { return a.split(""); }', objects={'a': 'abc'}) self.assertEqual(jsi.call_function('x'), ["a", "b", "c"]) + jsi = JSInterpreter(''' + function a(x) { return x; } + function b(x) { return x; } + function c() { return [a, b][0](0); } + ''') + self.assertEqual(jsi.call_function('c'), 0) def test_getfield(self): jsi = JSInterpreter('function c() { return a.var; }', objects={'a': {'var': 3}}) diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index 86b4f5488..35d2c535f 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -58,7 +58,7 @@ _LITERAL_RE = r'((?P%(int)s)|(?P%(float)s)|(?P%(str)s)|(?P