diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index d3076298cc..17184d5b0d 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -403,6 +403,8 @@ class TestJSInterpreter(unittest.TestCase): test_result = list('test') tests = [ 'function f(a, b){return a.split(b)}', + 'function f(a, b){return a["split"](b)}', + 'function f(a, b){let x = ["split"]; return a[x[0]](b)}', 'function f(a, b){return String.prototype.split.call(a, b)}', 'function f(a, b){return String.prototype.split.apply(a, [b])}', ] diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py index d46b78f64f..5e452aa674 100644 --- a/yt_dlp/jsinterp.py +++ b/yt_dlp/jsinterp.py @@ -614,7 +614,7 @@ class JSInterpreter: )|(?P (?P{_NAME_RE})\[(?P.+)\]$ )|(?P - (?P{_NAME_RE})(?:(?P\?)?\.(?P[^(]+)|\[(?P[^\]]+)\])\s* + (?P{_NAME_RE})(?:(?P\?)?\.(?P[^(]+)|\[(?P[^\[\]]+(?:\[[^\[\]]+(?:\[[^\]]+\])?\])?)\])\s* )|(?P (?P{_NAME_RE})\((?P.*)\)$ )''', expr)