aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordirkf <fieldhouse@gmx.net>2025-03-25 22:30:08 +0000
committerdirkf <fieldhouse@gmx.net>2025-03-25 22:35:06 +0000
commit1bc45b8b6c0c853e0f3d74346551fec0708c733d (patch)
tree70cfa5a70faebf011ad773bebe5f902e161520a5
parentb982d77d0b7bd21ead6d8b3210fd656881197453 (diff)
[JSInterp] Use `,` for join() with null/undefined argument
Eg: [1,2,3].join(null) -> '1,2,3'
-rw-r--r--youtube_dl/jsinterp.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py
index 186d2594a..f0c4fa928 100644
--- a/youtube_dl/jsinterp.py
+++ b/youtube_dl/jsinterp.py
@@ -1208,9 +1208,10 @@ class JSInterpreter(object):
elif member == 'join':
assertion(isinstance(obj, list), 'must be applied on a list')
assertion(len(argvals) <= 1, 'takes at most one argument')
- return (',' if len(argvals) == 0 else argvals[0]).join(
- ('' if x in (None, JS_Undefined) else _js_toString(x))
- for x in obj)
+ return (',' if len(argvals) == 0 or argvals[0] in (None, JS_Undefined)
+ else argvals[0]).join(
+ ('' if x in (None, JS_Undefined) else _js_toString(x))
+ for x in obj)
elif member == 'reverse':
assertion(not argvals, 'does not take any arguments')
obj.reverse()