]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[utils] Extract sanitize_url routine
authorSergey M․ <dstftw@gmail.com>
Sat, 26 Mar 2016 13:33:57 +0000 (19:33 +0600)
committerSergey M․ <dstftw@gmail.com>
Sat, 26 Mar 2016 13:33:57 +0000 (19:33 +0600)
youtube_dl/utils.py

index eacd81bf9ad3c733c578ace81cd7bf03ebff4725..6d27b80c02912b01b7f64ef85f20097f8216abe4 100644 (file)
@@ -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):