diff options
author | dirkf <fieldhouse@gmx.net> | 2025-03-10 11:44:06 +0000 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2025-03-11 02:00:24 +0000 |
commit | 420d53387cff54ea1fccca061438d59bdb50a39c (patch) | |
tree | 8fed7f10d050c700fb7562c1ba5bb0c32372ec0e /youtube_dl/jsinterp.py | |
parent | 32f89de92b652bf246aa458a552c9bb397abef77 (diff) |
[JSInterp] Improve tests
* from yt-dlp/yt-dlp#12313
* also fix d7c2708
Diffstat (limited to 'youtube_dl/jsinterp.py')
-rw-r--r-- | youtube_dl/jsinterp.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index 5a45fbb03..d9b33fa44 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -154,6 +154,7 @@ def _js_to_primitive(v): ) +# more exact: yt-dlp/yt-dlp#12110 def _js_toString(v): return ( 'undefined' if v is JS_Undefined @@ -162,7 +163,7 @@ def _js_toString(v): else 'null' if v is None # bool <= int: do this first else ('false', 'true')[v] if isinstance(v, bool) - else '{0:.7f}'.format(v).rstrip('.0') if isinstance(v, compat_numeric_types) + else re.sub(r'(?<=\d)\.?0*$', '', '{0:.7f}'.format(v)) if isinstance(v, compat_numeric_types) else _js_to_primitive(v)) |