From: Sergey M․ Date: Sat, 26 Mar 2016 13:33:57 +0000 (+0600) Subject: [utils] Extract sanitize_url routine X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=17bcc626bf67453cc5ab67e56684b6c6e33f4cb6;p=youtube-dl [utils] Extract sanitize_url routine --- diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index eacd81bf9..6d27b80c0 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -417,9 +417,12 @@ def sanitize_path(s): # Prepend protocol-less URLs with `http:` scheme in order to mitigate the number of # unwanted failures due to missing protocol +def sanitize_url(url): + return 'http:%s' % url if url.startswith('//') else url + + def sanitized_Request(url, *args, **kwargs): - return compat_urllib_request.Request( - 'http:%s' % url if url.startswith('//') else url, *args, **kwargs) + return compat_urllib_request.Request(sanitize_url(url), *args, **kwargs) def orderedSet(iterable):