Fix yt_validate stack overflow issue

https://github.com/play-dl/play-dl/issues/304

yt_validate was recursing forever because the regex for removing
the 'list=xxxx' parameter was looking for one or more characters
after list=, rather than 0 or more, so removed nothing if
no value was provided.

e.g https://www.youtube.com/playlist?list=

Have tested this locally but would appreciate a second look before merging.
This commit is contained in:
Alex Clarke 2022-06-09 10:11:01 +01:00
parent 8d71600624
commit 7ae5bc3e13
No known key found for this signature in database
GPG Key ID: 65594A5AF2D9F46F

View File

@ -61,7 +61,7 @@ export function yt_validate(url: string): 'playlist' | 'video' | 'search' | fals
else return 'search';
}
} else {
if (!url_.match(playlist_pattern)) return yt_validate(url_.replace(/(\?|\&)list=[^&]+/, ''));
if (!url_.match(playlist_pattern)) return yt_validate(url_.replace(/(\?|\&)list=[^&]*/, ''));
else return 'playlist';
}
}