aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-03-26 19:33:57 +0600
committerSergey M․ <dstftw@gmail.com>2016-03-26 19:33:57 +0600
commit17bcc626bf67453cc5ab67e56684b6c6e33f4cb6 (patch)
tree4b2baa937c5aea7b98e3b7b0812bf948ba29ee30 /youtube_dl/utils.py
parentb5a5bbf3764a3912a1d07816b6e91560fe1d8a10 (diff)
[utils] Extract sanitize_url routine
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py7
1 files changed, 5 insertions, 2 deletions
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):